function checkEmail($email){
$sql = "SELECT email FROM users WHERE email='".$email."'";
$conn = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "prs";
} else {
echo "0 results";
}
}
我有这个功能。当我运行脚本时出现错误:注意:尝试在第21行的...中获取非对象的属性(if($ result-> num_rows> 0))。有什么问题?
答案 0 :(得分:0)
或许查询结果为null 检查结果
if(isset($result) && !empty($result)){
if ($result->num_rows > 0)
{
echo "prs";
}
else
{
echo "0 results";
}
}
else
echo('0 results');