不好意思,新手上来问一下:
require_once 'connDB.php';
class a
{
public $query;
public $res;
.
.private function _getResult()
{
    $this->query = 'select * from table';
    $this->res =& $mdb2->query($this->query);
    /$mdb2是连接库的变量,在connDB.php 中
    if (PEAR::isError($this->res)) 
   {
        die($this->res->getMessage());
    }else{$row = $this->res->fetchRow();}
}
}运行后出现Fatal error: Call to a member function query() on a non-object in ... line 33库的连接是正常的

解决方案 »

  1.   

    上面的line 33是指这行:$this->res =& $mdb2->query($this->query);
      

  2.   

    问题解决了,在private function _getResult()这里添加一个传递变量private function _getResult(&$mdb2)就可以了
      

  3.   

    你的CLASS结构定义有问题吧.$mdb2 又是一个什么 class???
      

  4.   

    $mdb2是连接数据库的对象,是在连接数据库的类中定义的。我是通过Pear::MDB2来连接数据库的。谢谢你哦!