當我嘗試與地方代碼中插入數據:我儘量讓地方插入SQL中,但它給我一個錯誤
$query = dbConnect()->prepare("INSERT INTO users(key) WHERE mail='$mail' VALUES ('$key')");
我使用的XAMPP,它給了我一個錯誤:
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key) WHERE mail='[email protected]' VALUES (key)' at line 1 in C:\xampp\htdocs\PHP7_login\restore\index.php:38
它會,因爲SQL不允許[插入](http://dev.mysql.com/doc/refman/5.7/en/insert.html)與WHERE子句,除非你從一張桌子到另一個桌子 –
'鑰匙'是一個保留字 –
那裏,2次罷工。 –