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?
Reply to discussion (solution)
Ask a master to give a method
The database link timed out or exceeded the no-action timeout setting was forcibly broken by the database, and the other might be database instability. Persistent connections are not recommended ~ ~ Also not recommended to get large data results at one time ~
function Dbconnect ($hostname, $username, $pass, $db _name, $pconnect = 0) { $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;}
The recommended query is complete, close the connection database