[英]mysqli num_rows returning zero
i'm new to mysqli trying to select everything from a table but num_rows function is returning 0 what am i doing wrong?我是 mysqli 的新手,试图从表中选择所有内容,但 num_rows 函数返回 0 我做错了什么?
here is my code这是我的代码
<?php $conn = new mysqli('localhost', 'root', '', 'paa');
$sql='SELECT * FROM utilisateurs';
$rs=$conn->query($sql);
if($rs === false) {
trigger_error('Wrong SQL: '.$sql.'Error:'.$conn>error,E_USER_ERROR);
} else {
$rows_returned = $rs->num_rows;
echo $rows_returned;
}
?>
Apart from the $conn>error,E_USER_ERROR
which should be $conn->error,E_USER_ERROR
there is no error in your code.除了
$conn>error,E_USER_ERROR
应该是$conn->error,E_USER_ERROR
,您的代码中没有错误。 Maybe the table is empty?也许桌子是空的?
This function returns the number of rows found by the query.此函数返回查询找到的行数。 0 means that your query returned no rows.
0 表示您的查询没有返回任何行。
The question why did it so is neither on topic not have any means to be answered.为什么这样做的问题既不是主题也没有任何方法可以回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.