Warning: mysqli_query() expects parameter 1 to be mysqli, object given in
classmysqlConnextendssqlCrud{private$conn;private$table;private$server;private$userna...
class mysqlConn extends sqlCrud{
private $conn;
private $table;
private $server;
private $username;
private $password;
public function mysqlConn($server,$username,$password,$table){
$this->conn=mysqli_connect("$this->server","$this->username","$this->password",$this->table);
if(!$this->conn){
die(mysql_error());
}
}
}
$mysqlconn=new mysqlConn("localhost","root","123456","test");
$sql="SELECT * FROM test";
$query=mysqli_query($mysqlconn,$sql) or die(mysql_error());
最后一句为什么错了? 展开
private $conn;
private $table;
private $server;
private $username;
private $password;
public function mysqlConn($server,$username,$password,$table){
$this->conn=mysqli_connect("$this->server","$this->username","$this->password",$this->table);
if(!$this->conn){
die(mysql_error());
}
}
}
$mysqlconn=new mysqlConn("localhost","root","123456","test");
$sql="SELECT * FROM test";
$query=mysqli_query($mysqlconn,$sql) or die(mysql_error());
最后一句为什么错了? 展开
2个回答
2014-12-17 · 知道合伙人软件行家
关注
展开全部
mysql_query();你这里面的参数写反了吧,这是例子:
<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT * FROM Person";
mysql_query($sql,$con);
// 一些代码
mysql_close($con);
?>
<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT * FROM Person";
mysql_query($sql,$con);
// 一些代码
mysql_close($con);
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询