Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    Question Checking if a site is accessible?

    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

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah ok I seem to get the desired result when I add a @ infront of the fopen..

    just incase anyone else needs this:
    PHP Code:
    <?php

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

    if (!
    $file) {

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

    fclose($file);

    ?>

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    $file = @fopen("http://www.remixwars.com/", "r");

    That'll sort that error out

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    haha,, not fast enough!
    but thanks anyway

    -Ken


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •