View Full Version : file get contents problem arose

01-17-2010, 04:00 PM
So I have had a cron job running a script with file get contents. It was working good for probably over a few weeks, and all the sudden I am getting errors such as:

Warning: file_get_contents(***) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

I'm not sure If I have to update anything or not, but nothing was changed in the file.

sir pannels
01-17-2010, 04:04 PM

Can you show us the crontab entry?

Also, what happens if you run the script manually, not from cron?


01-17-2010, 04:14 PM
That's what happens when I try running it without. Not sure why, it was working great for a few weeks+

/usr/bin/php -q /home2/voroghco/public_html/PHP/Crons/***.php

If that is what you mean by the crontab entry. If you mean the file, I'll post that too.

01-17-2010, 05:29 PM
The error gives away what the problem is. You need to check the URL that it is calling, as it's giving a 404 now so it's probably been moved due to your script constantly calling it

01-17-2010, 06:00 PM
The file is still there, you can go to the exact url, and it is still there. I talked to the person who has the site that I am calling, and he has not changed anything.

01-17-2010, 09:05 PM
Sometimes in your crons you need to have the full path to your files that you are working with on your server.

Instead of just:

$contents = file_get_contents("path/to/my_file.php");

Try this instead:

$contents = file_get_contents("/home2/voroghco/public_html/path/to/my_file.php");

Odd that it would stop working all of a sudden... hopefully this helps.

01-17-2010, 10:42 PM
Hey Zoic!

Well, the file_get_contents accesses another persons website on a different server. So I have the file_get_contents(pathtofile).

example: file_get_contents(http://www.site.com/file.php/ect..)

01-17-2010, 10:50 PM
Sorry, didn't read the rest of the posts entirely. :)

See what happens when you use fsockopen (http://www.php.net/fsockopen).

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);

The above is taken from the first example.

01-19-2010, 09:54 PM
Alright, I'll try it when I get some time, thanks.

Nope, fsockopen does not work.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum