TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-30-2008, 08:08 PM   #1 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default Is This Possible?

Hi everyone,

I'm trying to insert data into a database which has part of a row filled in and part empty. For example, my database has the following structure: userID, user_name, user_pass, user_confirm_pass, user_email, user_address and user_postcode. All of the data is filled in except user_address and user_postcode. I have a section on the website that allows the user to fill in these details and then submit them to the database, but I can't get it working.

I think it's because as I said, part of the row is already filled it. Is is possible to add data to a row which already contains some data?

Thanks in advance,
Steven
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
Old 05-30-2008, 08:16 PM   #2 (permalink)
Jmz
The Acquainted
 
Join Date: Oct 2007
Location: Newcastle, UK
Posts: 113
Thanks: 3
Jmz is on a distinguished road
Default

If I understand what you mean, you just need to look at mysql update.

More info here: PHP MySQL Update
__________________
Free CSS Tutorials
Send a message via MSN to Jmz
Jmz is offline  
Reply With Quote
The Following User Says Thank You to Jmz For This Useful Post:
StevenF (05-31-2008)
Old 05-30-2008, 08:52 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You understood it as I understood it, Jmz. So I think you're right in saying the UPDATE keyword will allow you to do just that.

sql Code:
UPDATE myTable SET myNameRow = 'Adam' WHERE myIdRow = 5
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
StevenF (05-31-2008)
Old 05-31-2008, 08:41 PM   #4 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default

Hi guys,

Sorry I didn't explain it very well, this is what I mean. My database looks like this at the moment:

http://img229.imageshack.us/img229/2905/dbqh5.jpg

Now at a future date I would like to update user_address and user_postcode without changing any other data. I have the query and everything else set up, but I'm not sure if I can actually add data to part of a row which is empty.
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
Old 05-31-2008, 08:47 PM   #5 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Yes, you can, using the UPDATE query that everybody has been describing above. It permits for changing data or adding new data to an existing row without deleting old existing data.
-m
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
StevenF (05-31-2008)
Old 05-31-2008, 11:06 PM   #6 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default

Thank guys! I had actually tried that before but I was using the wrong syntax for my query.

Cheers,
Steven
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
Old 06-01-2008, 05:58 PM   #7 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

i understood what you want, your basically writing a update statement and in this statement your putting all the column names whether its empty or with data and setting the data to update based on what was entered on the webpage.

to allow an empty field to update as empty make sure that column or field doesnt have the not null selected so that you will be able to update it witout data.

im thinking that you used the update or insert statement and had set the column to not null and that when you tried to insert or update you were getting errors.
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 06-01-2008, 08:13 PM   #8 (permalink)
The Contributor
 
Join Date: May 2008
Location: Denmark
Posts: 70
Thanks: 3
SpYkE112 is on a distinguished road
Default

He could also choose just to update the fields who actually is different :)
SpYkE112 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:21 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design