哪位大神帮忙解决一下 谢谢
Fatal error: Call to a member function fetch_array() on a non-object in D:\www2\admin\cwgl\zhuanzhang.php on line 149
这是源码
<?php
include_once("../../include/newpage.php");
$sql = "select id from ag_zhenren_zz where 1=1";
if(isset($_GET["live_type"])){
if($_GET["live_type"] != '') $sql .= " and live_type='".$_GET["live_type"]."'";
}
if(isset($_GET["ok"])){
if($_GET["ok"] != '') $sql .= " and ok='".$_GET["ok"]."'";
}
if($_GET["username"]){
$sql .= " and username ='".$_GET["username"]."'";
}
if($_GET["zz_time"]){
if($time_type == 'CN'){
$stime = date("Y-m-d H:i:s",strtotime($_GET["zz_time"])-43200);
$etime = date("Y-m-d H:i:s",strtotime($stime)+86399);
}else{
$stime = $_GET["zz_time"].' 00:00:00';
$etime = $_GET["zz_time"].' 23:59:59';
}
$sql .= " and zz_time>='$stime' and zz_time<='$etime' ";
}
$sql .= " order by id desc ";
$query = $mysqli->query($sql);
var_dump($query);
$sum = $mysqli->affected_rows; //总页数
$thisPage = 1;
if($_GET['page']){
$thisPage = $_GET['page'];
}
$page = new newPage();
$thisPage = $page->check_Page($thisPage,$sum,20,40);
$id = '';
$i = 1; //记录 uid 数
$start = ($thisPage-1)*20+1;
$end = $thisPage*20;
while($row = $query->fetch_array()){ //出错位置
if($i >= $start && $i <= $end){
$id .= $row['id'].',';
}
if($i > $end) break;
$i++;
}
if($id){
$id = rtrim($id,',');
$sql = "select * from ag_zhenren_zz where id in ($id) order by id desc";
$query = $mysqli->query($sql);
$inmoney=0;
$outmoney=0;
根据你报错信息来看 $query->fetch_array() 这个方法返回的数据 是空的,是否是表里没有数据?
你把PHP执行的SQL打印出来,在数据库里执行一次看看是否有数据。
恩 好的 谢谢