我用类写了一个操作mysql的类可是不知道是怎么回事我的编辑器和浏览器总提示PHP Fatal error: Call to undefined function mysql_query() in D:\www\cmq\mysql.php on line 29
我实在找不到哪儿出错了,有那位高手给我解决一下,谢谢!
我的mysql类如下:
<?php
class mysql{
private $host;
private $name;
private $pass;
private $db;
private $ut;
private $link;
function _construct($host,$name,$pass,$db,$ut){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->table=$db;
$this->ut=$ut;
$this->connect(); }
function connect(){
$this->link=mysql_connect($this->host,$this->name,$this->pass);//or die($this->error());
mysql_select_db($this->db,$this->link) or die($this->error());
mysql_query("SET NAMES '$this->ut'");
} function query($sql) {
//if(!($result=mysql_query($sql))) echo $sql;
//$result
return mysql_query($sql)or die($this->error());
//return $result;
}
function num_rows($result) {
return @mysql_num_rows($result);
} function fetch_row($result) {
return mysql_fetch_row($result);
}
function error(){
return mysql_error();
} function close() {
return mysql_close();
} }
$db = new mysql('localhost','root','517209','cmq','gb2312');
$sql="select * from message";
$rs=$db->query($sql);
while($row=$db->fetch_row($rs))
{
echo "<table width='70%' height='20%'>";
echo "<tr><td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."<td></tr>";
}
echo "</table>";
?>
!!!!!!注:我就用普通的方法来调用库里面的函数都好着呢
我实在找不到哪儿出错了,有那位高手给我解决一下,谢谢!
我的mysql类如下:
<?php
class mysql{
private $host;
private $name;
private $pass;
private $db;
private $ut;
private $link;
function _construct($host,$name,$pass,$db,$ut){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->table=$db;
$this->ut=$ut;
$this->connect(); }
function connect(){
$this->link=mysql_connect($this->host,$this->name,$this->pass);//or die($this->error());
mysql_select_db($this->db,$this->link) or die($this->error());
mysql_query("SET NAMES '$this->ut'");
} function query($sql) {
//if(!($result=mysql_query($sql))) echo $sql;
//$result
return mysql_query($sql)or die($this->error());
//return $result;
}
function num_rows($result) {
return @mysql_num_rows($result);
} function fetch_row($result) {
return mysql_fetch_row($result);
}
function error(){
return mysql_error();
} function close() {
return mysql_close();
} }
$db = new mysql('localhost','root','517209','cmq','gb2312');
$sql="select * from message";
$rs=$db->query($sql);
while($row=$db->fetch_row($rs))
{
echo "<table width='70%' height='20%'>";
echo "<tr><td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."<td></tr>";
}
echo "</table>";
?>
!!!!!!注:我就用普通的方法来调用库里面的函数都好着呢
我晕,你看看,你有return吗?
没有$db就是空的
return mysql_query($sql)or die($this->error());
你看看mysql_query($sql) 对象句柄都没有
mysql_query($sql,$this->link) or die('');
你看看有没有问题
linux下,没有加载php_mysql.so