SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    0 Post(s)
    0 Thread(s)

    Use fopen to see if web site is down?


    I have a link to a site that, unfortunately, goes down with some frequency. So I'm trying to figure out how to check to make sure the site is up, and if so, display certain output (a frames page, actually), and, if not, redirect to a different site. Here's my code, with the "else" stuff stipped out for brevity's sake, and with the code commented out:

    // $file=fopen("","r");
    // if(!$file) {
    // header("Location:");
    // }

    And here are the error messages I get:

    Warning: php_network_getaddresses: getaddrinfo failed: no address associated with name in /usr/home/v1/yadayada/html/performances/tickets_online.php
    on line 2

    Warning: fopen("","r") - Bad file descriptor in /usr/home/v1/yadayada/html/performances/tickets_online.php on line 2

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/v1/yadayada/html/performances/tickets_online.php:2) in
    /usr/home/v1/yadayada/html/performances/tickets_online.php on line 4

    Am I missing something obvious? Is there another way that I should be trying to accomplish this same task? Thanks for any help!

  2. #2
    SitePoint Member
    Join Date
    Oct 2001
    0 Post(s)
    0 Thread(s)


    I'm not sure how to do it the way you were thinking, but will this work for you?
    PHP Code:
    fsockopen (""80$errno$errstr30);
    if (!
    $fp) {
    } else {
    It's basicly taken off of's manual, about fsockopen() command.


Posting Permissions

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