身份验证时PHPass出错

身份验证时PHPass出错,php,mysql,mysqli,Php,Mysql,Mysqli,我使用PHPass进行密码加密和登录验证 尝试登录时,会出现以下错误:_ 警告:mysqli::prepare()[mysqli.prepare]:第41行的无效对象或资源C:\mysqli rootfile blahblahblah\includes\user.php 致命错误:对第43行C:\rootfile blahblahblah\includes\user.php中的非对象调用成员函数bind_param() 我按照手册进行身份验证,但由于某些原因,它无法工作 这是身份验证功能的代码

我使用PHPass进行密码加密和登录验证

尝试登录时,会出现以下错误:_

警告:mysqli::prepare()[mysqli.prepare]:第41行的无效对象或资源C:\mysqli rootfile blahblahblah\includes\user.php

致命错误:对第43行C:\rootfile blahblahblah\includes\user.php中的非对象调用成员函数bind_param()

我按照手册进行身份验证,但由于某些原因,它无法工作

这是身份验证功能的代码

   public static function authenticate($username, $password)
{
    $pwdhasher = new PasswordHash(8, FALSE);
    $hashed_pwd = $pwdhasher->HashPassword($password);

    $db = new mysqli();
$stmt = $db->prepare("SELECT hashed_password FROM users WHERE username=? LIMIT 1");
    if (!$stmt) die($db->error);
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->bind_result($hashed_pwd);


if ($pwdhasher->CheckPassword($password, $hashed_pwd)) {
    return true;
} else {
    return false;
}
unset($pwdhasher);

}
对于运行函数的login.php页面:_

$username = $database->escape_value(trim($_POST['username']));
$password = $database->escape_value(trim($_POST['password']));

    $user = User::find_by_id(1);
    $found_user = User::authenticate($username, $password);

    if ($found_user)
    {
        $session->login($found_user, $user);
        $message = "You have Logged in.";
        redirect_to("index.php");
    }
    else { $message = "Incorrect username/password."; }

}
我找了很多东西,试了很多东西,但都没有用/


现在你看,我想要的是检查数据库中的用户名和哈希密码并登录,如果它们正确,我知道如何检查password()并用哈希密码加密,但我找不到如何使其验证用户名和密码….

看起来在使用和连接MySQLi时有问题,与phpass无关。