Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 恼人的mysql更新查询问题_Php_Mysql - Fatal编程技术网

Php 恼人的mysql更新查询问题

Php 恼人的mysql更新查询问题,php,mysql,Php,Mysql,我正在尝试使用php中的mysql_查询进行更新,它给了我以下错误: 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 我已经看了我的查询大约10分钟了,我找不到有什么问题。这是: if ($row['

我正在尝试使用php中的mysql_查询进行更新,它给了我以下错误:

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
我已经看了我的查询大约10分钟了,我找不到有什么问题。这是:

    if ($row['read'] == 0) {
        mysql_query("UPDATE mail SET read='1' WHERE id='$mailid'") or die(mysql_error());
    }  
有人知道错误在哪里吗?

那么

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

read
是一个保留字

将其放入背面标记中:

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

read
是一个保留字。你需要使用backticks`around read.

@krafs然后你应该将此答案设置为正确答案,然后单击此答案左侧的勾号。Chouchenos我知道:D。但这会迫使我等待10分钟才能接受答案。谢谢,提前10秒!尽管他提出了具体的观点:保留字,这是很重要的,参见这里的参考: