我試圖運行下面的查詢:與綁定PHP PDO UPDATE查詢參數
$sth = "UPDATE `users` SET users_password VALUES (:hash) WHERE users_id = $users_id";
$q = $conn->prepare($sth);
$q->execute(array(':hash'=>$hash));
但即時得到以下幾點:
Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'VALUES ('$2y$12$Ao46iC7W9Lj8FFfSmAaeoeQs9O.3QRVtDbHAyvpzH90YIUN61ma8i') WHERE us' at line 1'
任何想法?
(是的代碼是不是在一個try,catch塊還只是在試驗他們的幾件事情時刻)
的'VALUES'子句屬於'INSERT'查詢,而不屬於'UPDATE'。 – mario
爲什麼不綁定users_id? –
哇謝謝馬里奧,真的很有幫助感謝您的解決方案... – twigg