开发者

Annoying mysql update query problem

开发者 https://www.devze.com 2023-01-24 09:23 出处:网络
I\'m trying to update using mysql_query in php and it gives me this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to

I'm trying to update using mysql_query in php and it gives me this 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='1' WHERE id='14'' at line 1

I've been looking at my query for about 10 minutes now and I cant find whats wrong with it. He开发者_如何学Gore it is:

    if ($row['read'] == 0) {
        mysql_query("UPDATE mail SET read='1' WHERE id='$mailid'") or die(mysql_error());
    }  

Do anyone see where the error is?


read is a reserved word.

Enclose it into the backticks:

UPDATE mail SET `read`='1' WHERE id='$mailid'


How about...

"UPDATE `mail` SET `read`='1' WHERE `id`='".$mailid."'"


read is a reserved word. You need to use backticks ` around read.

0

精彩评论

暂无评论...
验证码 换一张
取 消