|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
update multiple columns using mysql UPDATE
Hi,
I'm trying to update multiple columns in my db but I keep getting errors with the SQL. I'm using stripslashes and urlencode before I update the columns but it only seems to work if I try to update 1 column at a time ? PHP Code:
This throws this error ? PHP Code:
This a real pain in the butt, do I have to use 3 seperate querries to alter the data in a single row ???? surely not. Thanks in advance, Jon |
|
#2
|
|||
|
|||
|
ok, I've tried just updating 1 column (title, date, body) and they all work fine that way so why doesn't it work when Itry to update 3 at once ??? I've changed urlencode to htmlentities but that hasn't helped, any ideas ?
Thanks, Jon |
|
#3
|
|||
|
|||
|
Right, I;ve got it to work like this:
PHP Code:
so I know my data is in a correct format but to do it that way seems total overkill. bummer, Jon |
|
#4
|
||||
|
||||
|
Try:
PHP Code:
If your ID is an integer, you shouldn't need quotes around $ID. (And your ID should probably be an auto-incremented ingeter unless you've got another primary key set that fills this role.) Note also that you don't need a "SET" for each column. Use SET and then give a comma-delimited name=value listing of updates. Also, putting stuff into the database, you probably want to add slashes rather than stripping them. PHP should automatically decode the query string into plain text (removing %20 and other such special characters and converting them back into spaces, quotes, etc.). And if somebody happens to put a single quote in the form blanks they've filled out, your query will be hosed up unless you add slashes. You strip slashes when pulling the data back out for display. |
|
#5
|
|||
|
|||
|
I've been working on a script for a few days 50% of it works in terms of installing the data from one table to another. The part that has me stumped is getting it to update the data.
So I took the query I used to generate the rows and tried an update script, even though I'm not getting any failure messages it not updating the required table..... Would greatly appreciate some help here. PHP Code:
Stuart |
|
#6
|
|||
|
|||
|
Any idea's anyone.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > update multiple columns using mysql UPDATE |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|