我的网站老是提示“数据库连接过多”而无法连接到数据库。但是我问了空间商,说MYSQL连接数是500,我站人本来就不多,肯定是够用的,下面是我的数据库连接类,你们看看有没有什么问题。
<?
#############
#数据库链接类#
#############class data_class{

private $data_name;
private $user_name;
private $user_pass;
private $data_address;
private $conn;function __get($property_name){
if(isset($this->$property_name)){
return ($this->$property_name);
}else{
return (NULL);
}
}function __set($property_name,$value){
$this->$property_name=$value;
}function __construct($ip,$data,$user,$pass){
$this->data_address=$ip;
$this->data_name=$data;
$this->user_name=$user;
$this->user_pass=$pass;
$this->conn=mysql_connect($this->data_address,$this->user_name,$this->user_pass) or die("
<?xml version=\"1.0\" encoding=\"utf-8\"?>\n
<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">\n
<html xmlns=\"http://www.w3.org/1999/xhtml\">\n
<head>\n
<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\"/>\n
<meta http-equiv=\"Cache-Control\" content=\"ust-revalidate\" forua=\"true\"/>\n
<meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/>\n
    <meta http-equiv=\"Cache-Control\" content=\"max-age=0\" forua=\"true\"/>\n
    <meta http-equiv=\"Expires\" content=\"0\" forua=\"true\"/>\n
    <meta http-equiv=\"Pragma\" content=\"no-cache\" forua=\"true\"/>\n
<link rel=\"shortcut icon\" href=\"/favicon.ico\" />\n
<title>网站维护中</title>
</head>
    <body>
网站正在升级.....请稍后访问……<br/>
<body>
</html>
");
$this->query("set names 'utf8'");
mysql_select_db("$this->data_name",$this->conn);

}function query($sql){
return mysql_query($sql,$this->conn);
}
function __destruct(){
if($this->conn){
mysql_close($this->conn);
}
}}
?>

解决方案 »

  1.   

    人家说的MYSQL连接数500又不是指配给你500,如果是虚拟主机的话,一台机器上几十个网站都正常呢。
    你的代码没什么问题。
      

  2.   

    不是,具体情况是这样的我的是手机网站,手机可以用cmwap和cmnet两个上网方式。
    当我用cmwap方式上网的时候,能看到的下载完了,下载的进度的就完了,而当我用cmnet方式联网的时候,眼睛能看到的下载完了,进度才显示下载了一般。就是这样的呢。