【发布时间】:2015-09-04 00:41:57
【问题描述】:
设置分页,$result1 正在从表中获取所有行,$new_result 设置其限制。
但是我收到一个错误“致命错误:在/home/....中的非对象上调用成员function fetch_assoc()”
$page_limit = 28;
$table_name_3 = 'table';
if (!isset($_GET['page']) )
{ $start=0; } else
{ $start = ($_GET['page'] - 1) * $page_limit; }
$mysqli = new mysqli("xxxxxxx" , "xxxxxxx" , "xxxxxxx" , "xxxxxxxxx");
$result1 = $mysqli->query( "SELECT * FROM $table_name_3
WHERE `categories` LIKE '$newq'
AND `inStock` LIKE 'true' ");
while ( $rows = $result1->fetch_assoc() ) {
$new_result = $mysqli->query( $rows . "LIMIT $start,$page_limit " );
while ( $rows = $new_result->fetch_assoc() ) {
$total = mysqli_num_rows($result);
$store = $rows['store'];
$productId = $rows['productId'];
【问题讨论】:
-
你不能这样做,你用一个字符串连接数组,bdway我不是反对它的人
-
检查您的数据库连接是否正常
-
不要在while循环中使用while
-
在 yoyr mysqli 后面添加
or die($mysqli->error)->查询并告诉我们您得到的确切错误是什么