出错信息:Fatal error: Call to a member function fetchrow() on a non-object in D:\webhost\hhoem2\web\comm\access_class.php on line 46求助高人帮忙分析下,看看是什么原因,,access_class.php全文如下:
<?php
if(!defined('INC'))
{
exit("Request Error!");
}/*********************************
access类
* *************************/
$db = new database();
$dh = new database();
$dsql = new database();
$func = new database();
class database {
var $link;
var $res;
var $total; //总的记录数
var $pagesize; //每页显示的记录数
var $pagecount; //总页数
var $page; //当前页数
var $n;
var $rows;
function database($debug=false) {
include($GLOBALS['myadodb']);
$drive="driver={Microsoft Access Driver (*.mdb)};Dbq=".realpath($GLOBALS['mydb']).";Uid=;Pwd=;";
$this->link=NewADOConnection("access");
$this->link->Connect($drive);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if($debug)
$this->link->debug=true;
}
function ErrorMsg(){
return $this->link->ErrorMsg();
}
function query($query) {
return $this->res=$this->link->Execute($query);
} function num_rows() {
return $this->res->numrows();
}
function fetchrow(){
return $this->res->fetchrow();
}
function insert($table,$field){
if(empty($table)) return false;
if(empty($field)) return false;
if(empty($this->link)) return false;
$temp=explode(',',$field);
$ins='';
for($i=0;$i<count($temp);$i++){
$ins.="'".$_POST[$temp[$i]]."',";
}
$ins=substr($ins,0,-1);
$query="insert into ".$table."(".$field.") values(".$ins.")";
return $this->query($query);
}
function update($table,$field,$where){
if(empty($table)) return false;
if(empty($field)) return false;
if(empty($this->link)) return false;
$temp=explode(',',$field);
$ins='';
for($i=0;$i<count($temp);$i++){
$ins.="$temp[$i]='".$_POST[$temp[$i]]."',";
}
$ins=substr($ins,0,-1);
$query="update ".$table." set ".$ins." where ".$where;
return $this->query($query);
}
function delete($table,$where){
if(empty($table)) return false;
if(empty($where)) return false;
if(empty($this->link)) return false;
$query="delete from ".$table." where ".$where;
return $this->query($query);
}
function pagesize($n=""){
if(empty($n))
$this->pagesize=15;
else
$this->pagesize=$n;
}
function getpage($query){ //取总页数
$this->query($query);
return $this->pagecount = ceil($this->num_rows() / $this->pagesize);
}
function get_num_pl($page){ //取的LIMIT的前一个参数(开始ROW数) if($page==""||!is_numeric($page))
$page=1;
$this->n=$this->pagesize*($page-1);
}
function selectlimit($query="",$page){
if(empty($query)) return false;
if(empty($this->link)) return false;
if($page==""||!is_numeric($page))
$page=1;
$n=$this->pagesize*($page-1);
$this->res = $this->link->SelectLimit($query, $this->pagesize,$n);
}
function showpage($query){ //显示分页的内容
$this->selectlimit($query);
while($this->rows=$this->res->fetchrow())
{
echo $rows[1]; //你想读出的字段,自己添加
echo $rows[2]."<br>";
}
}
function updowmpage($table,$id,$classtype="",$type=""){
if(empty($table)) return false;
if(empty($id)) return false;
if($type!="")
$type=' ';
else
$type="<br>";
if($classtype!="")
$query ="select top 1 * from $table where id<$id and type='".$classtype."' order by id desc";
else
$query ="select top 1 * from $table where id<$id order by id desc";
$this->query($query);
$rows=$this->fetchrow();
if($rows[0]=="")
$pagestr="上一篇:没有上一条记录".$type;
else
$pagestr="<a href='?id=".$rows[0]."&classtype=".urlencode($classtype)."'>上一篇: ".$rows[1]."</a>".$type;
if($classtype!="")
$query="select top 1 * from $table where id>$id and type='".$classtype."' order by id asc";
else
$query="select top 1 * from $table where id>$id order by id asc";
$this->query($query);
$rows=$this->fetchrow();
if($rows[0]=="")
$pagestr.="下一篇: 没有下一条记录";
else
$pagestr.="<a href='?id=".$rows[0]."&classtype=".urlencode($classtype)."'>下一篇: ".$rows[1]."</a>"; return $pagestr;
}}
?>
<?php
if(!defined('INC'))
{
exit("Request Error!");
}/*********************************
access类
* *************************/
$db = new database();
$dh = new database();
$dsql = new database();
$func = new database();
class database {
var $link;
var $res;
var $total; //总的记录数
var $pagesize; //每页显示的记录数
var $pagecount; //总页数
var $page; //当前页数
var $n;
var $rows;
function database($debug=false) {
include($GLOBALS['myadodb']);
$drive="driver={Microsoft Access Driver (*.mdb)};Dbq=".realpath($GLOBALS['mydb']).";Uid=;Pwd=;";
$this->link=NewADOConnection("access");
$this->link->Connect($drive);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if($debug)
$this->link->debug=true;
}
function ErrorMsg(){
return $this->link->ErrorMsg();
}
function query($query) {
return $this->res=$this->link->Execute($query);
} function num_rows() {
return $this->res->numrows();
}
function fetchrow(){
return $this->res->fetchrow();
}
function insert($table,$field){
if(empty($table)) return false;
if(empty($field)) return false;
if(empty($this->link)) return false;
$temp=explode(',',$field);
$ins='';
for($i=0;$i<count($temp);$i++){
$ins.="'".$_POST[$temp[$i]]."',";
}
$ins=substr($ins,0,-1);
$query="insert into ".$table."(".$field.") values(".$ins.")";
return $this->query($query);
}
function update($table,$field,$where){
if(empty($table)) return false;
if(empty($field)) return false;
if(empty($this->link)) return false;
$temp=explode(',',$field);
$ins='';
for($i=0;$i<count($temp);$i++){
$ins.="$temp[$i]='".$_POST[$temp[$i]]."',";
}
$ins=substr($ins,0,-1);
$query="update ".$table." set ".$ins." where ".$where;
return $this->query($query);
}
function delete($table,$where){
if(empty($table)) return false;
if(empty($where)) return false;
if(empty($this->link)) return false;
$query="delete from ".$table." where ".$where;
return $this->query($query);
}
function pagesize($n=""){
if(empty($n))
$this->pagesize=15;
else
$this->pagesize=$n;
}
function getpage($query){ //取总页数
$this->query($query);
return $this->pagecount = ceil($this->num_rows() / $this->pagesize);
}
function get_num_pl($page){ //取的LIMIT的前一个参数(开始ROW数) if($page==""||!is_numeric($page))
$page=1;
$this->n=$this->pagesize*($page-1);
}
function selectlimit($query="",$page){
if(empty($query)) return false;
if(empty($this->link)) return false;
if($page==""||!is_numeric($page))
$page=1;
$n=$this->pagesize*($page-1);
$this->res = $this->link->SelectLimit($query, $this->pagesize,$n);
}
function showpage($query){ //显示分页的内容
$this->selectlimit($query);
while($this->rows=$this->res->fetchrow())
{
echo $rows[1]; //你想读出的字段,自己添加
echo $rows[2]."<br>";
}
}
function updowmpage($table,$id,$classtype="",$type=""){
if(empty($table)) return false;
if(empty($id)) return false;
if($type!="")
$type=' ';
else
$type="<br>";
if($classtype!="")
$query ="select top 1 * from $table where id<$id and type='".$classtype."' order by id desc";
else
$query ="select top 1 * from $table where id<$id order by id desc";
$this->query($query);
$rows=$this->fetchrow();
if($rows[0]=="")
$pagestr="上一篇:没有上一条记录".$type;
else
$pagestr="<a href='?id=".$rows[0]."&classtype=".urlencode($classtype)."'>上一篇: ".$rows[1]."</a>".$type;
if($classtype!="")
$query="select top 1 * from $table where id>$id and type='".$classtype."' order by id asc";
else
$query="select top 1 * from $table where id>$id order by id asc";
$this->query($query);
$rows=$this->fetchrow();
if($rows[0]=="")
$pagestr.="下一篇: 没有下一条记录";
else
$pagestr.="<a href='?id=".$rows[0]."&classtype=".urlencode($classtype)."'>下一篇: ".$rows[1]."</a>"; return $pagestr;
}}
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货