Jump to content

[SOLVED] Update Query not working


YourNameHere

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/168368-solved-update-query-not-working/
Share on other sites

"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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.