PHP Long connection database caused MySQL has gone away
Public Function connect () {
if ($this->conn = = "Pconn") {
Permanent links
$this->conn = mysql_pconnect ($this->db_host, $this->db_user, $this->db_pwd);
} else {
Even if the link
$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 ("Database unavailable:", $this->db_database);
}
}
mysql_query ("SET NAMES $this->coding");
}
The above is affixed to the database connection of the writing, how can I write to do not appear errors? Is there any other way to do it?
Share to:
------Solution--------------------
{
$func = Empty ($pconnect)? ' Mysql_connect ': ' Mysql_pconnect ';
if (! $connect) {
$connect = @ $func ($hostname, $username, $pass) or Die ("Mysql_error:". Mysql_error (). "
Mysql Error Num: ". Mysql_errno ().");
}
@mysql_select_db ($db _name, $connect) or Die ("Mysql_error:". Mysql_error (). "
Mysql Error Num: ". Mysql_errno ().");
return $connect;
}