开发者

SQL insert error [closed]

开发者 https://www.devze.com 2023-01-23 15:53 出处:网络
This question is unlikely to help开发者_如何学Python any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is n
This question is unlikely to help开发者_如何学Python any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.
 $query = "INSERT INTO event (eventDesc) ".
          "VALUES ('".$eventDesc."') WHERE event = 'Testing'";

is there something wrong with this statement?

I'm getting error saying:

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 'WHERE event = 'Testing'' at line 2


You want to use an UPDATE statement to update an existing value:

$query = sprintf("UPDATE EVENT
                     SET eventDesc = '%s'  
                   WHERE event = 'Testing'",
                  mysql_real_escape_string($eventDesc));

This is safer than your query -- no risk of SQL injection attack.


There is no such thing as a WHERE clause in an INSERT query.

0

精彩评论

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

关注公众号