mysqli_num_rows($ R);总是返回0

时间:2017-11-01 22:36:34

标签: php mysql mysqli

$myusername = mysqli_real_escape_string($dbc,$_POST['username']);
$mypassword = mysqli_real_escape_string($dbc,$_POST['Password']); 

$sql = "SELECT id FROM Users WHERE email = '$myusername' and pass = 
'$mypassword'";

$r = @mysqli_query($dbc,$sql);
$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
$active = $row['active'];


$count = mysqli_num_rows($r);
print $count;

if($count == 1) {

header('Location: http://localhost/Hw3/index.php');

}else {

     echo '<p class="error">Your Login Name or Password is invalid</p>';
  }

我正在尝试从数据库中获取用户名和密码,并使用$count = mysqli_num_rows($r)检查它们是否是最新的;但即使用户名和密码正确,计数也始终返回 0

0 个答案:

没有答案