SQL insert error [closed]
$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.
精彩评论