mysql_ping -- Ping a server connection or reconnect if there is no connection
Syntax
bool mysql_ping ( [resource link_identifier] )
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.
Parameters
link_identifier
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() was called
with no arguments. If by chance no connection is found or established, an
E_WARNING level warning is generated.
Return Values
Returns TRUE if the connection to the server MySQL server is working,
otherwise FALSE.
/* Assuming this query will take a long time */ $result = mysql_query($sql); if (!$result) { echo 'Query #1 failed, exiting.'; exit; }
/* Make sure the connection is still alive, if not, try to reconnect */ if (!mysql_ping($conn)) { echo 'Lost connection, exiting after query #1'; exit; } mysql_free_result($result);
/* So the connection is still alive, let's run another query */ $result2 = mysql_query($sql2); ?>
mysql ping php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online
Php mysql ping syntax tutorial
php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.