password_hash字段未更新

时间:2016-07-19 18:27:51

标签: mysql

这是一个更改密码的函数.. 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 = ?");
它工作正常。

0 个答案:

没有答案