PHP 4 >= 4.3.0, PHP 5
mysql_ping - Ping a server connection or reconnect if there is no connection
Code Examples

mysql_ping( [resource$link_identifier = NULL] ): bool

Checks whether or not the connection to the server is working. If it has gone down, an automatic reconnection is attempted. This function can be used by scripts that remain idle for a long while, to check whether or not the server has closed the connection and reconnect if necessary.


Automatic reconnection is disabled by default in versions of MySQL >= 5.0.3.



The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect is assumed. If no such link is found, it will try to create one as if mysql_connect had been called with no arguments. If no connection is found or established, an E_WARNING level error is generated.

Return Values

Returns true if the connection to the server MySQL server is working, otherwise false.

Related Functions

Example of mysql_ping

Show all examples for mysql_ping

PHP Version: