Home > Backend Development > PHP Tutorial > Solution to PHP connection mysql timeout

Solution to PHP connection mysql timeout

WBOY
Release: 2016-07-25 09:05:38
Original
1396 people have browsed it
  1. function reconnect(){
  2. if (!mysql_ping ($this->db)) {
  3. //here is the major trick, you have to close the connection (even though it is not currently working) for it to recreate properly. Mysql_close($this->db);
  4. $this->connect(); has been disconnected If it is open, if it is disconnected, close the current link and re-create a new connection.
  5. In this way, as long as the connection is found to be disconnected, it can be reconnected.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template