Page 1 of 1

sometimes it works sometimes it results in error

Posted: Wed Nov 23, 2005 4:16 pm
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

Posted: Wed Nov 23, 2005 4:26 pm
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....