我是PHP的初学者。当我尝试做mysql_num_rows时,它给出了一个错误:
警告:mysql_num_rows()期望参数1是资源,对象 在第22行的D:\ xampp \ htdocs \ kcp \ police \ viewcase.php中给出
这是代码:
<?php
session_start();
if(empty($_SESSION['pusername'])||empty($_SESSION['pid']))
{
header('location://localhost/kcp/police_login.html');
exit();
}
else
{
$station=$_SESSION['station'];
$con = mysqli_connect('localhost','root','','kcp');
if(!$con)
{
echo 'NOT CONNECTED TO DB';
}
$sql="SELECT * FROM complaint WHERE station='$station'";
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$res=mysqli_query($con,$sql) or die("llllllll");
$numrow=mysql_num_rows($res);
echo $numrow;
}
?>
答案 0 :(得分:5)
答案 1 :(得分:0)
使用mysqli_num_rows而不是mysql_num_rows