Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP错误get_result()未定义的方法_Php - Fatal编程技术网

PHP错误get_result()未定义的方法

PHP错误get_result()未定义的方法,php,Php,我是这个论坛的新手,所以我会尽力的。 我的PHP代码有一个错误,因为我的服务器主机不支持mysqlnd驱动程序。我知道我必须使用bind_result();但我不知道该怎么做(我正在学习) 请帮帮我!谢谢 代码如下: /** * Storing new user * returns user details */ public function storeUser($name, $email, $password) { $uuid = uniqid('', true); $

我是这个论坛的新手,所以我会尽力的。 我的PHP代码有一个错误,因为我的服务器主机不支持mysqlnd驱动程序。我知道我必须使用bind_result();但我不知道该怎么做(我正在学习)

请帮帮我!谢谢

代码如下:

/**
 * Storing new user
 * returns user details
 */
public function storeUser($name, $email, $password) {
    $uuid = uniqid('', true);
    $hash = $this->hashSSHA($password);
    $encrypted_password = $hash["encrypted"]; // encrypted password
    $salt = $hash["salt"]; // salt

    $stmt = $this->conn->prepare("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES(?, ?, ?, ?, ?, NOW())");
    $stmt->bind_param("sssss", $uuid, $name, $email, $encrypted_password, $salt);
    $result = $stmt->execute();
    $stmt->close();

    // check for successful store
    if ($result) {
        $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");
        $stmt->bind_param("s", $email);
        $stmt->execute();
        // Error here
        $user = $stmt->get_result()->fetch_assoc();
        $stmt->close();

        return $user;
    } else {
        return false;
    }
}

/**
 * Get user by email and password
 */
public function getUserByEmailAndPassword($email, $password) {

    $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");

    $stmt->bind_param("s", $email);

    if ($stmt->execute()) {
        // Error here
        $user = $stmt->get_result()->fetch_assoc();
        $stmt->close();

        // verifying user password
        $salt = $user['salt'];
        $encrypted_password = $user['encrypted_password'];
        $hash = $this->checkhashSSHA($salt, $password);
        // check for password equality
        if ($encrypted_password == $hash) {
            // user authentication details are correct
            return $user;
        }
    } else {
        return NULL;
    }
}

在此处出现
错误后,必须将
$stmt
替换为
$result

$result = $stmt->execute(); 
// Error here     $user=$result->get_result()->fetch_assoc();
$stmt->execute()$user=$stmt->get_result()->fetch_assoc()将其更改为
$result=$stmt->execute()$user=$result->get_result()->fetch_assoc()这是Log.d“对非对象调用成员函数get_result()”。。。在“调用未定义的方法mysqli_stmt::get_result()”之前。。。有什么想法吗?