sometimes it works sometimes it results in error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bluesman333
Forum Commoner
Posts: 52
Joined: Wed Dec 31, 2003 9:47 am

sometimes it works sometimes it results in error

Post by bluesman333 »

Some times this scirpt will work, other times it returns an error:

Code: Select all

<?php

set_time_limit(0);

$url = 'http://site/xml_feed.php';

$page = file_get_contents($url);

print $page;


?>
Here is the error:
Warning: file_get_contents(http://site/xml_feed.php): failed to open stream: HTTP request failed! in /usr/home/public_html/test.php on line 7

It seems to work everyother time it is loaded. Is that a coincidence?

Any suggestions
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Post by trukfixer »

sounds like the http request is being dropped - I would say either the connection or the server on the other end is breaking down and not working right. think of file_get_contents() using an http:// request to be *JUST LIKE* hitting the same URL with a web browser - if the connection, DNS, or webserver serving the website you are requesting doesnt deliver the goods, you get an http request failed, I would say...

I never use url fopens or file_get_contents to get something from a remote machine or URL especially not with set_timeout(0)... just too many things can go wrong with that and causing your script to load up the server it runs on..... so.. I have very little experience in doing this sort of thing....
Post Reply