how do i fix this error? this is my code.
$stmt = $this->conn->prepare("SELECT ngno, email, encrypted_password, name, user_type FROM `guide` WHERE email = ?");
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$user = $stmt->bind_result($ngno, $email, $encrypted_password, $name, $user_type)->fetch_assoc();
$stmt->close();
im using a remote sql database. i have also tried this on my localhost. but then i get the error, fatal error call to a member function fetch_assoc() on boolean
this code worked with get_result instead of bind_result. but i need to use bind_result. Any help would be appreciated.
EDIT 1:
i have changed the code to the following,
$stmt = $this->conn->prepare("SELECT ngno, email, encrypted_password, name, user_type FROM `guide` WHERE email = ?");
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$stmt->bind_result($ngno, $email, $encrypted_password, $name, $user_type);
$user = $stmt->fetch_assoc();
$stmt->close();
if($encrypted_password == $password){
return $user;
}
} else {
return NULL;
}
i get this error now. Fatal error: Call to undefined method mysqli_stmt::fetch_assoc()
Is my query failing?
No comments:
Post a Comment