以下是简单获取操作的代码: -
$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';
}
它不打印'null',但不打印任何内容。 它是PHP版本的区别,在localhost为5.5,在服务器为5.4.9?
答案 0 :(得分:0)
尝试使用此代码查看会发生什么:
$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';
}