AV1611 Posted March 7, 2007 Share Posted March 7, 2007 I have a script that does this: $site="http://".$url."/".$url."/pbsvss.htm"; $lines = file($site); If the IP is valid, the punkbuster screenshot list for that server is output, and I can parse out the document to check for hackers, etc... If the wrong IP is given (Or the server is misconfigured) you get this: Warning: file(http://1.2.2.2/1.2.2.2/pbsvss.htm) [function.file]: failed to open stream: Connection timed out in /home/osprey/public_html/aao/whoisonaserver.php on line 14 Warning: Invalid argument supplied for foreach() in /home/osprey/public_html/aao/whoisonaserver.php on line 17 What I need is instead of that message, is a simple clause that I can put my own error message i.e. "The server is not responding, Check the IP or contact the server Admin" IF (worked) {parse} else {error message} Link to comment https://forums.phpfreaks.com/topic/41645-solved-making-error-clause/ Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 <?php $site="http://".$url."/".$url."/pbsvss.htm"; if (!$lines = @file($site)) { echo "The server is not responding, Check the IP or contact the server Admin"; } ?> Link to comment https://forums.phpfreaks.com/topic/41645-solved-making-error-clause/#findComment-201793 Share on other sites More sharing options...
AV1611 Posted March 7, 2007 Author Share Posted March 7, 2007 My hero Link to comment https://forums.phpfreaks.com/topic/41645-solved-making-error-clause/#findComment-201796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.