我应该用什么替换代码来验证如果查询结果行是 = 1"?
我已经尝试了很多使用 num_rows 的方法,但它不起作用.
我的 PHP 代码:
What should I replace 'CODE TO VERIFY IF QUERY RESULT ROW IS = 1' for?
I've tried many ways using num_rows but it won't work.
My PHP code:
$con=mysqli_connect("localhost","mbrconsu_un394x","y1cz9,rd+hf6","mbrconsu_mmx");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$usuario = $con->real_escape_string($_GET['usuario']);
$senha = $con->real_escape_string($_GET['senha']);
$query = mysqli_query($con, "SELECT * FROM 'login' WHERE usuario = '$usuario' AND senha='$senha'");
if(CODE TO VERIFY IF QUERY RESULT ROW IS = 1){
while($row = mysqli_fetch_assoc($query)){
$db_username = $row['usuario'];
$db_password = $row['senha'];
}
if($usuario == $db_username && $senha == $db_password){
return true;
}
} else {
return false;
}
mysqli_close($con);
?>
$query->num_rows;
或
mysqli_num_rows($query);
这篇关于如何计算查询结果行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!