How to use mysql ping in PHP

In this article I am going to explain about mysql_ping function in PHP.
  • 2464

PHP mysql_ping() Function

The PHP mysql_ping function pings a server connection or reconnect to a MySQL server. This function returns true if there is no connection, or false on failure.

Syntax of mysql_ping function

mysql_ping(connection)

Parameters in mysql_ping function

It has only one parameter:

Parameter Description
connection It is optional parameter and it specifies a MySQL connetion.

Example of mysql_ping function

<?php

$con=mysql_connect("localhost","gupta","sharad");

if(!$con)

{

die("Could not connect:".mysql_error());

}

mysql_select_db("mcn_solution",$con);

$res=mysql_query("select * from emp");

echo "Success= ".mysql_ping();

mysql_close($con);

?>


Output:

mysql-ping-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.