这是一个更改密码的函数.. mysql表名是users
并且有password_hash
字段,可以保存哈希密码..字段类型是文本
public function changePassword($userId, $password) {
$password_hash = PassHash::hash($password);
$stmt = $this->conn->prepare("UPDATE users set password_hash = $password_hash where id = ?");
$stmt->bind_param("i", $userId);
$result = $stmt->execute();
$stmt->close();
if ($result) {
return true;
}
else{
return false;
}
}
当我在邮递员中跑步时,我收到错误......
Fatal error: Call to a member function bind_param() on boolean in /Applications/XAMPP/xamppfiles/htdocs/step_muzic/include/DbHandler.php on line 200
....但是当我更改行
时$stmt = $this->conn->prepare("UPDATE users set password_hash = $password_hash where id = ?");
到
$stmt = $this->conn->prepare("UPDATE users set password_hash = $password where id = ?");
它工作正常。