Php “如何调试”;mysqli_fetch_array()希望参数1是mysqli_result,布尔值为“给定”;?
我是PHP新手,它正在展示 “警告:mysqli_fetch_array()希望参数1为 mysqli_结果,给定布尔值“ 我的代码是:Php “如何调试”;mysqli_fetch_array()希望参数1是mysqli_result,布尔值为“给定”;?,php,Php,我是PHP新手,它正在展示 “警告:mysqli_fetch_array()希望参数1为 mysqli_结果,给定布尔值“ 我的代码是: <?php include_once 'Conn.php'; $qry="select * from sumit"; $res= mysqli_query($GLOBALS['link'],$qry); echo '<table border="5">'; echo '<tr><th>Empno</th&
<?php
include_once 'Conn.php';
$qry="select * from sumit";
$res= mysqli_query($GLOBALS['link'],$qry);
echo '<table border="5">';
echo '<tr><th>Empno</th><th>Name</th><th>Adress</th><th>Salary</th></tr>';
while($r= mysqli_fetch_array($res))
{
echo "<tr><td>$r[0]</td><td>$r[1]</td><td>$r[2]</td><td>$r[3]</td></tr>";
}
echo '</table>';
顺便说一句,虽然这不能解决您的问题,但在访问记录时可能会有所帮助。如果您使用
mysqli\u fetch\u object
,则可以更轻松地检索imho记录。例如:
include 'conn.php';
$con=$GLOBALS['link'];
if( is_object( $con ) ){
$sql='select * from `city` limit 10';
$res=mysqli_query( $con, $sql );
if( $res ){
while( $rs = mysqli_fetch_object( $res ) ) echo '<div>'.$rs->Name. ' '.$rs->CountryCode.' '.$rs->District.' '.$rs->Population.'</div>';
}
mysqli_free_result( $res );
mysqli_close( $con );
$con=null;
}
包括“conn.php”;
$con=$GLOBALS['link'];
if(is_object($con)){
$sql='select*来自'city`limit 10';
$res=mysqli\u查询($con,$sql);
如果($res){
而($rs=mysqli_fetch_object($res))回显“.$rs->Name.”.$rs->CountryCode.”.$rs->District.”.$rs->Population.”;
}
mysqli_免费_结果($res);
mysqli_close($con);
$con=null;
}
conn.phpuse mysqli_error($con)conn.php可以显示数据库“fresh”和表“sumit”的内容吗?我尝试使用这种方法创建连接对象并运行查询,这很好,因此,正如@ThinkDifferent建议的那样,您可以确认表确实存在,并且数据库是正确的。