...

View Full Version : Checking if a site is accessible?



angst
09-13-2005, 09:25 PM
Hello,
I've seen this done before, but not sure how it's done.

I have a data base of links, and I want to be able to loop through them and check if the links are working or dead.

could someone show me how this is done, or point me in the right direction?

thanks in advance for your time!
-Ken

angst
09-13-2005, 10:54 PM
ok,,
well i've tried this:

<?php

$file = fopen ("http://www.remixwars.com/", "r");

if (!$file) {

echo "Site is Down";
exit;
} else {
echo "Site is Up";
exit;
}

fclose($file);

?>

which seems to work fine is the site is up, but if it's down i get this error:

Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in \remote.php on line 3


ideas anyone??

-Ken

angst
09-13-2005, 10:58 PM
ah ok I seem to get the desired result when I add a @ infront of the fopen..

just incase anyone else needs this:


<?php

$file = @fopen ("http://www.remixwars.com/","r");

if (!$file) {

echo "Site is Down";
exit;
} else {
echo "Site is Up";
exit;
}

fclose($file);

?>

Nightfire
09-13-2005, 10:58 PM
$file = @fopen("http://www.remixwars.com/", "r");

That'll sort that error out

angst
09-13-2005, 11:00 PM
haha,, not fast enough!
but thanks anyway :thumbsup:

-Ken



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum