YourNameHere Posted August 1, 2009 Share Posted August 1, 2009 my mysql ver. is 5.0.51-community I have never used an update statement before so I don't know how to go about remedying this. UPDATE messages SET read = '0' Where id = 'a number' the php var is being set properly, i know this when I echo the statement out. What I get with mysql_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 'read = '0' Where id = '4 limit 1'' at line 1" I want the column to be updated to 0 if it is 1 where the id matches the php var. the only thing I tried was updating it manually in phpmyadmin and copying the statement into the script, and that did not work. here is that statement. UPDATE `a6936052_base`.`messages` SET `read` = '0' WHERE `messages`.`id` ='a number' LIMIT 1 that throws no errors but doesn't update it. Quote Link to comment https://forums.phpfreaks.com/topic/168368-solved-update-query-not-working/ Share on other sites More sharing options...
trq Posted August 1, 2009 Share Posted August 1, 2009 Can we see your actual code and what the statement looks like when it is printed to the screen? Quote Link to comment https://forums.phpfreaks.com/topic/168368-solved-update-query-not-working/#findComment-888162 Share on other sites More sharing options...
Zyx Posted August 1, 2009 Share Posted August 1, 2009 "read" is an SQL keyword. If you use SQL keywords as column/table names etc., they must be written in backticks. Actually it's good to write all the table and column names in backticks. If nothing is updated without any error, I would say that the row ID specified in the query is invalid - it must point to an existing row. Quote Link to comment https://forums.phpfreaks.com/topic/168368-solved-update-query-not-working/#findComment-888167 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.