Forum Moderators: coopster

Message Too Old, No Replies

Checking if a site is accessible?

         

angst

7:25 pm on Sep 13, 2005 (gmt 0)

10+ Year Member



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

8:56 pm on Sep 13, 2005 (gmt 0)

10+ Year Member



ok,,
well i've tried this:

<?php

$file = fopen ("http://www.example.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

[edited by: coopster at 6:19 pm (utc) on Sep. 14, 2005]
[edit reason] generalized url [/edit]

killroy

9:13 pm on Sep 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try cUrl. You'll be able to set a timeout to prevent long delays if the site is down and you might even be able to get the info without downloading hte page.

angst

9:22 pm on Sep 13, 2005 (gmt 0)

10+ Year Member



kool,
i'll give that a try

-Ken