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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.