我試圖運行此查詢:通過我的PHP腳本疑難解答PHP MySQL查詢
$q1 = "INSERT INTO `Validation` (`Key`, `Status`, `Notes`, `Serial`) VALUES (max(Key)+1, 'Valid', '".mysql_real_escape_string($user)."', '0')";
,但是每次都顯示此錯誤:
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 'Key)+1, 'Valid', 'USER', '0')' at line 1
任何想法?
您是否試圖模擬自動增加的ID?在這種情況下,你可以在列上使用AUTO_INCREMENT,它會爲你做到這一點。 – robbrit 2011-04-30 18:56:51