我有一个问题。我试图找出数据库中是否已存在用户的电子邮件,这是我的查询:
$stmt1 = "select EmailAddress from customers where EmailAddress = ' .$emailaddress. '";
$result = $db->query($stmt1);
if($result->num_rows === 0){
$Err = "";
} else {
$Err = 'This user is already registered login instead.';
}
我做错了什么?我似乎无法让num_rows返回我可以使用的东西。如果没有找到记录,此查询是否应该返回0;如果有记录,则不应该返回行数?
答案 0 :(得分:0)
使用:
$stmt1 = "SELECT EmailAddress FROM customers WHERE EmailAddress = '".$emailaddress."'";