Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in D:\www\cmq\mysql.php on line 34
PHP Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in D:\www\cmq\mysql.php on line 34
总是出现上面得情况,这是怎么回事吗 ,我的php配置都好着呢,我用面向过程的方法操作数据库都好着呢,可是我将操作数据库的所有方法封进类里就出现了如上的错误,谁能给我解决一下。
我写的mysql类如下:
<?php
   class mysql{
     private $host;
     private $name;
     private $pass;
     private $db;
     private $ut;
     private $link;
     function __construct($host,$name,$pass,$db,$ut){
         $this->host=$host;
         $this->name=$name;
         $this->pass=$pass;
         $this->db=$db;
         $this->ut=$ut;
         $this->connect();     }
     function connect(){
      $this->link=mysql_connect($this->host,$this->name,$this->pass);
      mysql_select_db($this->db,$this->link) or die($this->error());
      mysql_query("SET NAMES '$this->ut'");
     }    function query($sql) {
           return  mysql_query($sql)or die($this->error());
    }
    function num_rows($result) {
        return @mysql_num_rows($result);
    }    function fetch_row($result) {
        return mysql_fetch_row($result);
    }
        function fetch_object($result){
                 return mysql_fetch_object($result);
        }
        function error(){
               return mysql_error();
               }    function close() {
        return mysql_close();
    }   }
   $db =  new mysql('localhost','root','*******','cmq','gb2312');
     $sql="select * from message";
     $rs=$db->query($sql);
     $num=$db->num_rows($rs);
     // echo $num;
   echo "<table  width='70%' height='20%'>";
     while($row=$db->fetch_row($rs))
    {
       echo "<tr><td>".$row[1]."</td>";
       echo "<td>".$row[2]."</td>";
       echo "<td>".$row[3]."<td></tr>";
     }
   echo  "</table>";    
?>