<? php
class SqlTool{
private $conn;
private $host='localhost';
private $user="root";
private $password="root";
private $db="worddb";
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 dql
public function execute_dql($sql){
$res=mysql_query($sql,this->conn) or die(mysql_error());
return $res;
}//完成update delete insert dml
public function execute_dml($sql){
$b=mysql_query($sql,$this->conn);
//echo "添加的id=".mysql_insert_id($this->conn);
if(!$b){
return 0;//失败
}else{
if(mysql_affected_rows($this->conn)>0){
return 1;//成功
} else{
return 2;//表示没有影响的行数
}
}
}
}
?>
上面文件报错:
parse error:syntax error,unexpected T_CLASS in .......
请问是什么原因
class SqlTool{
private $conn;
private $host='localhost';
private $user="root";
private $password="root";
private $db="worddb";
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 dql
public function execute_dql($sql){
$res=mysql_query($sql,this->conn) or die(mysql_error());
return $res;
}//完成update delete insert dml
public function execute_dml($sql){
$b=mysql_query($sql,$this->conn);
//echo "添加的id=".mysql_insert_id($this->conn);
if(!$b){
return 0;//失败
}else{
if(mysql_affected_rows($this->conn)>0){
return 1;//成功
} else{
return 2;//表示没有影响的行数
}
}
}
}
?>
上面文件报错:
parse error:syntax error,unexpected T_CLASS in .......
请问是什么原因
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货