使用bind params的PHP PDO UPDATE查询

时间:2013-04-17 12:30:53

标签: php pdo

我正在尝试运行以下查询:

$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'

有什么想法吗?

(是的,代码不是一个尝试,抓住阻止,只是用一些东西试验他们的时刻)

1 个答案:

答案 0 :(得分:0)

更改此

$sth = "UPDATE `users` SET users_password VALUES (:hash) WHERE users_id = $users_id";

$sth = "UPDATE `users` SET users_password = :hash WHERE users_id = $users_id";