简体   繁体   English

MySQL语法错误问题

[英]Mysql syntax error issue

I've got a message while i'm run following sql query... 我正在按照sql查询运行时收到一条消息...

"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 'group = 'dfdfd' WHERE id = '39'' at line 1" “您的SQL语法有错误;请在与MySQL服务器版本相对应的手册中找到在第1行的'group ='dfdfd'WHERE id ='39'附近使用的正确语法”

Sql query: SQL查询:

$sql_update = mysql_query("UPDATE addcontacts SET surename = '$surname_g', group = 
'$g_g' WHERE id = '$id'");

Please use ` to enclose group, it is being treated as special ( group by keyword of SQL) by mysql 请使用`括起组,mysql将其视为特殊group by SQL group by关键字按group by

Use the following: 使用以下内容:

 UPDATE addcontacts SET surename = '$surname_g', `group` = '$g_g' WHERE id = '$id'

Note `group` and not group 注意`group`而不是group

尝试:

$sql_update = mysql_query("UPDATE addcontacts SET surename = '".$surname_g."', `group` = '".$g_g."' WHERE id = '".$id."'");

Your id might be an integer and you are enclosing it with two single quotes (') and that would really produce the error. 您的ID可能是整数,并且用两个单引号(')括起来,这确实会产生错误。

$sql_update = mysql_query("UPDATE addcontacts SET surename = '{$surname_g}', group = 
'{$g_g}' WHERE id = {$id}");

Thank you :) 谢谢 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM