class Connection extends mysqli {
protected $user;
protected $password;
protected $database;
protected $host;
protected $querymia;
protected $link;
function __construct($user,$pass,$database,$host){
$this->user=$user;
$this->password=$pass;
$this->database=$database;
$this->host=$host;
$this->link= mysqli_connect("$this->host","$this->user","$this->password","$this->database") or die("Error");
}
public function InsertQuery($string,$table){
$this->querymia = 'INSERT INTO' . "$table" . 'VALUE' . '(' . "$string".')' ;
$this->link->query($this->querymia);
}
}
答案 0 :(得分:1)
程序mysqli_connect
返回一个处理程序,不是一个对象。
因此,您应该使用mysqli_query($this->link, $this->querymia);
答案 1 :(得分:0)
整个错误应说明:Fatal error: Call to a member function query() on a non-object
。所以$this->link
不是一个对象。也许无法建立联系。
你应该添加一些代码:
if (!$this->link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
致电mysqli_connect()
之后或致电query()
之前;