> i have the problem that i need to connect to a database on a server wich
> is quiet often offline.
>
> how can i connect to this database (mysql) and can check if the server is
> online.
> like.. if server is online -> fine we work as normaly
> if server is NOT online -> print out message and say "server offline try
> later"....
>
> i tried something like mysql_connect and then die ...
> but it takes approx 5 mins.. till i get the message..
> do i have to set the timeout lower? and if yes.. how do i do that ?
This should do what you want:
system("ping -c 1 www.someurl.com", $retval);
if($retval == 0) {
#server is alive
}
else {
#server is down
}
HTH
-Marc-
#/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/#
#Marc Swanson | \|||/ #
#MSwanson Consulting | /o o\ #
#Phone: (603)868-1721 |-ooo----O----ooo-#
#Fax: (603)868-1730 | Solutions in: #
#[EMAIL PROTECTED] | 'PHP 'Perl #
# | 'SQL 'C++ #
# | 'HTML 'Sh/Csh#
# http://www.mswanson.com | 'Javascript #
#/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/#
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]