Halt error on fsockopen()

Halt error on fsockopen()

Posted by: psychichigh
Posted on: 2006-03-03 12:57:00

I got a script going to show the server status of some game servers to show if they're online or offline. But when a server is offline it also prints out the error message that fsockopen couldn't connect.

Is there a way to halt the error message from showing up?

In reply to:

while (list($servname, $servip) = each($servers)) {
if ($servname == 'Login Server') {
$servport = '15100';
} else {
$servport = '15001';
}

echo "$servname ";

$fp = fsockopen($servip, $servport, $errno, $error, 10);
if (!$fp) {
echo "<font color=#ff0000>Offline</font>n";
} else {
echo "<font color=#00ff00>Online</font>n";
fclose($fp);
}
}



Re: Halt error on fsockopen()

Posted by: ablio
Posted on: 2006-03-04 04:11:00

I think you can just stick in a @ in front of the function

Rails Hosting - DH supports Ruby on Rails!
Tip - use the DreamHost promo code X50 to get $50 off any of their plans instantly

Re: Halt error on fsockopen()

Posted by: psychichigh
Posted on: 2006-03-04 13:56:00

Thanks for the idea on this one. Trying it out, just waiting for the servers to go down next and see if it works.

Tags: error messageechoserver statusprints