PHP长时间连接数据库促成mysql has gone away
程序员文章站
2022-06-14 17:00:18
...
PHP长时间连接数据库造成mysql has gone away
public function connect() {
if ($this->conn == "pconn") {
//永久链接
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
//即使链接
$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}
if (!mysql_select_db($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error("数据库不可用:", $this->db_database);
}
}
mysql_query("SET NAMES $this->coding");
}
上面贴的是数据库连接的写法,请问怎么写能做到不出现错误呢?还有其他的方法吗?
public function connect() {
if ($this->conn == "pconn") {
//永久链接
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
//即使链接
$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}
if (!mysql_select_db($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error("数据库不可用:", $this->db_database);
}
}
mysql_query("SET NAMES $this->coding");
}
上面贴的是数据库连接的写法,请问怎么写能做到不出现错误呢?还有其他的方法吗?
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
推荐阅读
-
PHP长时间连接数据库造成mysql has gone away解决办法
-
PHP长时间连接数据库促成mysql has gone away
-
数据库还原提示MySQL server has gone away 的解决方法
-
mysql 远程连接出现MySQL server has gone away的解决办法
-
PHP程序mysql报错mysql has gone away
-
php用pdo的like查询语句,间接性报错 MySQL server has gone away
-
远程连接mysql 这几天一直出现 2006 'MySQL server has gone away'
-
PHP程序mysql报错mysql has gone away
-
php用pdo的like查询语句,间接性报错 MySQL server has gone away
-
php用pdo的like查询语句,间接性报错 MySQL server has gone away
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论