UPDATE 查询在 MySQL 5.0 中不起作用
我不完全确定我在这里做错了什么,我一次又一次地检查了错误放置的引号,但我一生都无法让这个更新查询代码工作......并且我已经解决了它查询本身给出了一个不正确的语法错误,但我不知道它出了什么问题,因为它与手册相同。
$change = mysql_query("UPDATE Images SET Group='$group' WHERE ID = '$imgid'") or
die(mysql_error());
I'm not completely sure what I'm doing wrong here I've looked through again and again for incorrectly placed quotes but I cannot for the life of me get this UPDATE query code to work... and I've troubleshooted it down to the query itself and it gives an incorrect syntax error, yet I have no idea what is wrong with it as it is identical to the manual.
$change = mysql_query("UPDATE Images SET Group='$group' WHERE ID = '$imgid'") or
die(mysql_error());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可能需要这样做:
因为 group 是 MySQL 中的关键字。
you might need to do :
as group is a keyword in MySQL .
好吧...如果更新不起作用,可能有两个原因。要么你的语法错误;这应该会导致 MySQL 抛出一个错误,该错误应该在您的
die(mysql_error())
中显示。或者根本没有与您的
WHERE
条件匹配的记录。要检查是否有任何记录已更新,您可能需要查看 mysql_affected_rows()。您可以使用相同的WHERE
条件在该表上运行SELECT
查询。Well... if the update does not work this might have two reasons. Either your syntax is wrong; this should result in MySQL throwing an error which should show up with your
die(mysql_error())
.Or there is simply no record matching your
WHERE
-condition. To check if any record was updated at all you might want to take a look at mysql_affected_rows(). And you could run aSELECT
-query on that table, using the sameWHERE
-condition.试试这个..
“UPDATE Images SET
Group
='”.$group.”' WHERE ID =“.$imgidtry this ..
"UPDATE Images SET
Group
='".$group."' WHERE ID = ".$imgid