Introduction: Why will appear Too many connections so wrong? The answer lies in PHP programs. Open the former colleagues to write programs and found that the pace of a run-in with too many calls mysql_pconnect function. If the application server, each one httpd child process to use a php script, php script to open each one more than one mysql connection. Produced because the httpd ...
Too many connections appear on the PHP issue
Ago a friend of mine asked me why his Web site appeared Too many connections error. Because I have not encountered this issue, when work is busy, no time to consider this issue. A few weeks ago, and now the company work, a friend told me that I am now the company's Web site the same problem, to an imperative need to figure out the point, and then in the PHP manual to find inside information on the mysql_connect and mysql_pconnect, The following is a php manual description of these two functions:
-------- Mysql_connect -----------
Prototype:
resource mysql_connect ([string server [, string username [, string password [, bool new_link [, int client_flags ]]]]])
Returns:
If successful, returns a MySQL Connection logo, failure returns FALSE.
Description:
mysql_connect () to establish a connection to MySQL server. When no optional parameters using the following default values: server = 'localhost: 3306', username =
Server process owner user name, password = empty password.
If you use the same argument a second call to mysql_connect (), will not create a new connection, but will return to the already opened connection ID. Parameters new_link change this behavior and to
mysql_connect () always open a new connection, even when the mysql_connect () has been used in the previous call had the same parameters. Client_flags parameter can be a combination of the following constants
: MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE.
Note: new_link parameters became available since PHP 4.2.0.
client_flags parameter became available since PHP 4.3.0.
Once the script to the end of the connection to the server will be shut down. Unless it had previously called mysql_close () to close it.
------- Mysql_pconnect -------------
Prototype:
resource mysql_pconnect ([string server [, string username [, string password [, int client_flags ]]]])
Returns:
If successful, returns a positive MySQL persistent link identifier, an error is returned FALSE.
Description:
mysql_pconnect () to establish a connection to MySQL server. If you do not provide optional parameters, use the following defaults: s



