'Getting error "Uncaught Error: Call to undefined method mysqli_stmt::fetch_array()", while checking existing email and mobile [duplicate]
I'm trying to register a user but first check if mobile and email already register. All other validations are done by jQuery and a request is sent by ajax to this PHP page. Everything is working fine if there is a new user, but that existing email and mobile checking part is not working. I'm getting this error -> "Uncaught Error: Call to undefined method mysqli_stmt::fetch_array()".some one please help.
<?php
require('db_connection.php');
if($_SERVER['REQUEST_METHOD']=="POST"){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$password=$_POST['password'];
$hashed_password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$sql = "SELECT `user_email`,`user_mobile` FROM `users` where `user_email` = ? OR `user_mobile` = ? LIMIT 1";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss",$email,$mobile);
$stmt->bind_result($email,$mobile);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows > 0){
$row = $stmt->fetch_array(MYSQLI_ASSOC);
if(isset($row['user_email']) == $email){
echo "email exists";
// exit();
}
if(isset($row['user_mobile']) == $mobile){
echo "mobile exists";
// exit();
}
}else{
$stmt= $conn->prepare("INSERT INTO `users`(`user_name`, `user_email`, `user_mobile`, `user_password`) values (?, ?, ?, ?)");
$stmt->bind_param("ssss",$name,$email,$mobile,$hashed_password);
$stmt->execute();
echo "successfull";
$stmt->close();
}
}
$conn->close();
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
