[html]
Insert title here
Insert title here
[php] view plaincopyprint?
class DicTool{
private $conn;
private $host = "localhost";
private $user = "root";
private $password = "123";
private $db = "test";
//构造函数,初始化数据,连接数据库
function __construct(){
$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");
}
function findchword($enword){
$sql = "select * from words where enword ='".$enword."'limit 0,10";
$res = mysql_query($sql,$this->conn) or die(mysql_error());
if (!$res){
return 0;//失败
}else{
$row = mysql_fetch_assoc($res);
return $row['chword'];
}
}
}
[php]
http://www.bkjia.com/PHPjc/477931.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477931.htmlTechArticle[html] !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd html head meta http-equiv=Content-Type content=text/html; charset=UTF-8 titl...
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:php中文网