SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Oct 19, 2001, 13:04 #1
Use fopen to see if web site is down?
Hi:
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:
<?php
// $file=fopen("http://www.ticketslive.com/","r");
// if(!$file) {
// header("Location:http://www.tickets.com/venue_info.cgi?VENUE_ID=00000");
// }
?>
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("http://www.ticketslive.com/","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!
-
Oct 19, 2001, 19:44 #2
- Join Date
- Oct 2001
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hum...
I'm not sure how to do it the way you were thinking, but will this work for you?
PHP Code:<?php
$fp = fsockopen ("www.php.net", 80, $errno, $errstr, 30);
if (!$fp) {
echo "Down!<br>\n";
} else {
echo "Up!<br>\n";
}
?>
Bookmarks