<?phpclassphptool {private$conn;private$host="localhost";private$user="root";private$password="root";private$db="php";functionsqlTool(){$this->conn=mysql_connect($this->ho...
class phptool{
private $conn;
private $host="localhost";
private $user="root";
private $password="root";
private $db="php";
function sqlTool(){
$this->conn=mysql_connect($this->host,$this->user,$this->password);
if(!$this->conn){
die("连接数据失败".mysql_error());
}
mysql_select_db($this->db,$this->conn);
mysql_query("set names utf8");
}
//完成查询select
function execute_dql($sql){
}
//完成 update,delete,insert
function execute_dml($sql){
$b=mysql_query($sql,$this->conn);
if(!$b){
return 0 ;//操作失败
}else{
if(mysql_affected_rows($this->conn)>0){
return 1 ;//表示成功;
}else{
return 2 ;//表示没有行数影响
}
}
mysql_close($conn);
}
}
?>
提示这句不对,$b=mysql_query($sql,$this->conn);我不知道在哪里错了!通过类实例就提示上面这个错误!
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\appserv\www\mysql1.php on line 29
失败
展开