将PHP版本5.2升级到7.3后,mysqli_fetch_assoc无法在while循环中工作
我不知道为什么会发生这种情况,因为有些函数在while循环中使用将PHP版本5.2升级到7.3后,mysqli_fetch_assoc无法在while循环中工作,php,mysqli,php-7.3,Php,Mysqli,Php 7.3,我不知道为什么会发生这种情况,因为有些函数在while循环中使用mysqli\u fetch\u assoc,而有些函数在while循环中不使用mysqli\u fetch\u assoc 我使用了以下PHP脚本 function get_customer_record_list($table,$pos_customer){ $sql = "SELECT * FROM ".$table." WHERE pos_customer = '$pos_customer' order by
mysqli\u fetch\u assoc
,而有些函数在while循环中不使用mysqli\u fetch\u assoc
我使用了以下PHP脚本
function get_customer_record_list($table,$pos_customer){
$sql = "SELECT * FROM ".$table." WHERE pos_customer = '$pos_customer' order by added_date DESC";
$select =mysqli_query($this->connect,$sql)or die("Query (List) is not executed.");
while($row = mysqli_fetch_assoc($select)){
$result [] = $row;
}
echo "working";exit();
//return $result;
}
关闭while loop
后不工作$result
值未打印,也不会在关闭循环后显示任何内容
数据库中有501
条记录,但使用mysqli\u fetch\u assoc
无法打印数据。我还尝试了mysqli\u fetch\u object
使用foreach
循环打印数据
我不知道为什么会发生这种情况。请检查,这应该可以。我已经添加了找到的行数的输出,然后打印结果
function get_customer_record_list($table,$pos_customer){
$sql = "SELECT * FROM ".$table." WHERE pos_customer = '$pos_customer' order by added_date DESC LIMIT 3";
$select =mysqli_query($this->connect,$sql)or die("Query (List) is not executed.");
$rowcount=mysqli_num_rows($select);
echo "Total Rows found-".$rowcount."\n<br>";
$count=0;
while($row = mysqli_fetch_assoc($select)){
echo "Loop ".$count."\n<br>";
$count++;
$result[] = $row;
}
echo "Total Iterations -".$count."\n<br>";
print_r($result);
//return $result;
}
函数获取客户记录列表($table,$pos\u customer){
$sql=“从“$table.”中选择*,其中pos_客户=“$pos_客户”订单按添加的日期描述限制3”;
$select=mysqli_query($this->connect,$sql)或die(“查询(列表)未执行”);
$rowcount=mysqli\u num\u行($select);
回显“找到的行总数-”$rowcount。“\n
”;
$count=0;
while($row=mysqli\u fetch\u assoc($select)){
回显“循环”。$count。“\n
”;
$count++;
$result[]=$row;
}
回显“总迭代次数-”$count。“\n
”;
打印(结果);
//返回$result;
}
您是否看到正在打印的正在工作
?什么是var\u dump($select)代码>?否,闭环后不打印任何内容。添加var\u dump($select)代码>在循环之前,您得到了什么?默认情况下,PHP7中禁用了MySQLi扩展。您需要从php.ini中启用它file@TusharMySQLi已经启用,我已经在问题中提到了一些功能正在工作,但不是这个。在loopTotal行501之后不打印任何内容,但在loopTotal行501之后不打印。在上面添加了一些跟踪日志,您能检查并让我们知道输出吗?在我的例子中,它工作正常现在它显示3个结果,但在查询中它没有通过限制,因为我总共有501条记录。它仍然显示105条记录,但如果我将限制设置为大于105,则显示空白不是工作。我想它应该是数组索引超出范围?