PHP mysqli_ping() Function

PHP mysqli_ping() function pings a server connection, or tries to reconnect if the connection has gone down.


bool mysqli_ping(connection);

mysqli_ping() Function Parameter

connection :Required parameter. The MySQL connection to be used

mysqli_ping() Function Return Value

Return Values :Returns TRUE on success or FALSE on failure.

mysqli_ping() Function Example

$con = mysqli_connect("localhost","user","password","db");

if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
if (mysqli_ping($con)) {
    echo "Connection is good";
} else {
    echo "Error in connection : ". mysqli_error($con));