PHP MySQL UPDATE

Hi All…
What am i doing wrong… just trying to update a mysql row with a bunch or php variables from a form…

using php5 and mysql 5

the PHP code…

$query = "UPDATE $dbtable SET 'Year' = '$Year', 'Issue' = '$Issue', 'Page' = '$Page', 'Title' = '$Title', 'Layout' = '$Layout', 'Locomotive' = '$Locomotive', 'Wagon' = '$Wagon', 'Coach' = '$Coach', 'Electrics' = '$Electrics', 'Couplings' = '$Couplings', 'Baseboards' = '$Baseboards', 'Track' = '$Track', 'Signaling' = '$Signaling', 'Scenery' = '$Scenery', 'Buildings' = '$Buildings', 'Design' = '$Design', 'Photography' = '$Photography', 'Hints' = '$Hints', 'Other' = '$Other', 'UK' = '$UK', 'USA' = '$USA', 'Japan' = '$Japan', 'Germany' = '$Germany', 'Swiss' = '$Swiss', 'Review' = '$Review', 'Books' = '$Books', 'Software' = '$Software' WHERE 'ID' = '$ID'";

$result = mysql_query($query);

the error i get…

Invalid query: 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 ''Year' = '1989', 'Issue' = '5', 'Page' = '19', 'Title' = 'Airfields in N', 'Layo' at line 1 Whole query: UPDATE journalindex SET 'Year' = '1989', 'Issue' = '5', 'Page' = '19', 'Title' = 'Airfields in N', 'Layout' = '6', 'Locomotive' = '0', 'Wagon' = '0', 'Coach' = '0', 'Electrics' = '0', 'Couplings' = '0', 'Baseboards' = '0', 'Track' = '0', 'Signaling' = '0', 'Scenery' = '1', 'Buildings' = '0', 'Design' = '0', 'Photography' = '0', 'Hints' = '0', 'Other' = '0', 'UK' = '0', 'USA' = '0', 'Japan' = '0', 'Germany' = '0', 'Swiss' = '0', 'Review' = '0', 'Books' = '0', 'Software' = '0' WHERE 'ID' = '3'

thanks for help…
cheers
steve

"UPDATE $dbtable SET ‘Year’ = ‘$Year’, …
Use backticks, not quotes for field names
"UPDATE $dbtable SET Year = ‘$Year’,

hash is correct. You can also do without the backticks only if there are no spaces in your field names.

Also, if your fields are numeric types, you won’t need single quotes around the values.

and if the column name is not a reserved word

:slight_smile: