I am trying to tell if my mysql server is running before the page loads. I thought that a good way to do it might be to put in this code:
$db = mysqli_connect("localhost:3306", "root", "", "hscct2003");
if (!$db)
{
die('Server Error: ' . mysql_error());
}
, but after about 30 seconds, my browser just output this error:
Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306:3306) in C:\wamp\www\military\index.php on line 39
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\military\index.php on line 39.
What I want to do is to put in the same code and if it doesn't respond (set a value to a variable) in 5 seconds, kill the function and echo some sort of error.
does anyone know how to tell if mysql is running or have any idea how to time a function?