插入或更新时出现Mysqli错误

时间:2014-10-07 01:54:20

标签: php mysqli

我有一个Query类:

    include_once("Mysql.php");
abstract class connection implements Mysql
    {

        public function connect() 
            { 
                $link=new mysqli("localhost",Mysql::username,Mysql::password);

                mysqli_select_db($link,Mysql::db);

                if ($link->connect_errno)
                    {
                        echo "Error mysql: %s\n,".$link->connect_error;
                    }

                return $link;
            } 
    }



class query extends connection{
    var $bd; //conexion mysql
    var $q; //query introducida
    var $n;//numero de resultados
    var $v;//los resultados en una tabla de objetos
    var $a;//numero de filas afectadas por la query

    function __construct($query)
    {
        $this->bd = $this->connect();
        $this->q = $query;
        $mysql_result = mysqli_query($this->bd,$query);
        $this->n = mysqli_num_rows($mysql_result);
        $this->a = mysqli_affected_rows($this->bd);

        if($this->n)
            for($i=0;$i<$this->n;$i++) $taula[$i] = $mysql_result->fetch_object();
        else $taula = null;
        $this->v = $taula;
        if(  $this->n > 0  ) mysqli_free_result($mysql_result);
    }

}

当我尝试运行插入查询时:

$query = new query("INSERT INTO content(title) VALUES('prueba')");

错误提示,无法将数据插入表格...

PHP Warning:  mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/olverabr/public_html/admin/class/Query.php on line 35

在它正常工作之前,但现在它已经无法正常工作了,请帮助我!

最诚挚的问候。

虚拟发布是相同但不是!,我插入不选择!...

0 个答案:

没有答案