doulan0297 2017-12-23 09:02
浏览 90
已采纳

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 2017-12-23 09:05
    关注

    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))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部