View Single Post
  #4 (permalink)
Old 1st August 2008, 05:56 PM
mbz-bugsy
CE - Newbie
 
I'm a Crazy Sofware Engineer
Join Date: 1st August 2008
Posts: 1
Smile Re: updating multiple columns in single MySQL table

Quote:
Originally Posted by hbk View Post
here is the code---

mysql_query("UPDATE table SET dod = '$dod' where ID = '$id' ");

mysql_query("UPDATE table SET mod = '$mod' where ID = '$id' ");

mysql_query("UPDATE table SET yod = '$yod' where ID = '$id' ");


the 1st and the 3rd query get executed, but no updation occurs thru the 2nd query.

I have even tried using a single query, but the same effect.

When i use mysql_error() with the second query, it reports the error --

You have an error in your SQL syntax, check the manual that corresponds to your MySQL server version for the right syntax to use near 'mod = '10' ,yod='2008' where ID =56 at line 1.


Somebody please help...

thx a ton...

Hi hbk,
I don’t know if it’s too late posting this, you might already have figured it out. When it comes to mysql, in your queries you must be careful when you want to update or insert data into columns with names that are usual parameters in mysql statements. For e.g ifyou want to update a column named update you must escape it with `, like UPDATE news set `update`=’value’. In this case the column mod, you must escape it with `. Like this

mysql_query("UPDATE table SET dod = '$dod', `mod`=’$mod’, yod =’$yod’ where ID = '$id' ");



Good luck

________________________
ILLUMINA
Web Dev Swe

Last edited by mbz-bugsy : 1st August 2008 at 06:22 PM.
mbz-bugsy is offline   Reply With Quote