Here's the following code for simple fetch operation:-
$con = new mysqli('localhost','xyz','xyz','xyz');
$stmt = $con->prepare("SELECT u.name,u.email,u.api_key,u.status FROM users u WHERE u.email = ?");
$stmt->bind_param('s',$email);
if($stmt->execute()){
$user = $stmt->get_result()->fetch_assoc();
var_dump($user);
$stmt->close();
}else{
echo 'null';
}
It does not prints 'null', but prints nothing. Is it the difference between PHP version which is 5.5 at localhost and 5.4.9 at server ?
Try this code to see what happens :
$con = mysqli_connect('localhost','xyz','xyz','xyz');
if(!$con){
die("Error : " . mysqli_error);
}
$stmt = $con->prepare("SELECT u.name,u.email,u.api_key,u.status FROM users u WHERE u.email = ?");
$stmt->bind_param('s',$email);
if($stmt->execute()){
$user = $stmt->get_result()->fetch_assoc();
var_dump($user);
$stmt->close();
}else{
echo 'null';
}