PHP mysqli_ping() Function
PHP MySQLi Reference
Example
Ping a server connection:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Check if server is alive
if (mysqli_ping($con))
{
echo "Connection is ok!";
}
else
{
echo "Error: ". mysqli_error($con);
}
mysqli_close($con);
?>
Definition and Usage
The mysqli_ping() function pings a server connection, or tries to reconnect if the
connection has gone down.
Syntax
| Parameter |
Description |
| connection |
Required. Specifies the MySQL connection to use |
Technical Details
| Return Value: |
TRUE on success. FALSE on failure |
| PHP Version: |
5+ |
PHP MySQLi Reference
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]