doulan0297
doulan0297
2017-12-23 17:02

mysqli_num_rows()期望参数1为mysqli_result,第12行的C:\ wamp \ www \ DbConnect.php中给出了字符串

已采纳

This is my php code and whenever i runs it i get that error ...database is on localhost wamp server

<?php
$username ="root";
$password= "";
$hostname ="localhost";
$database ="mydata";
$check="";
$conn = new mysqli($hostname, $username, $password, $database);
$i = "SELECT * FROM `patient` WHERE 1";
$num_rows = mysqli_num_rows($i);
while($row = mysqli_fetch_array($i))
{
$r[]=$row;
$check=$row["emailid"];
}
if($check==NULL)
{
$r[$num_rows]="Record is not available";
print(json_encode($r));
}
else
{
$r[$num_rows]="success";
print(json_encode($r));
}
//mysql_close($conn);
?>

please suggest the solution for this.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongmei2351 dongmei2351 4年前

    change your connection

    $conn=mysqli_connect($hostname, $username, $password, $database);
    

    you have wrong sql

    change this

    $i = "SELECT * FROM `patient` WHERE 1";
    

    to

    $i = "SELECT * FROM `patient` WHERE your_cloumn_name = 1";
    

    and you have not executed the your

    add

    $result=mysqli_query($conn,$i);
    

    and then

    while($row = mysqli_fetch_array($result))
    
    点赞 评论 复制链接分享