mysql_ping()


Request a connection state to the server

Description

bool mysql_ping(void)

Parameters

none

Return Value

On success true, otherwise false

Example

<?php
include_once "/lib/sn_mysql.php";

$server_addr = "192.168.0.100";          // IP address of MySQL server
$user_name = "user_id";                  // MySQL ID
$password = "password";                  // MySQL password

// connect to a MySQL server
if(mysql_connect($server_addr, $user_name, $password) === false)
    exit(mysql_error());                 // print the error message and quit

if(mysql_ping() === true)                   
    echo "connection is alive\r\n";         
else                                        
    echo "connection is dead\r\n";

mysql_close();                           // disconnecting from the MySQL server
?>

See also