Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts

    file get contents problem arose

    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.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Hi,

    Can you show us the crontab entry?

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

    Cheers,

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    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
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    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.

  • #6
    New Coder
    Join Date
    Jan 2010
    Location
    UT
    Posts
    35
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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:
    PHP Code:
    $contents file_get_contents("path/to/my_file.php"); 
    Try this instead:
    PHP Code:
    $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.

  • #7
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    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..)

  • #8
    New Coder
    Join Date
    Jan 2010
    Location
    UT
    Posts
    35
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Sorry, didn't read the rest of the posts entirely.

    See what happens when you use fsockopen.

    PHP Code:
    <?php
    $fp 
    fsockopen("www.example.com"80$errno$errstr30);
    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($fp128);
        }
        
    fclose($fp);
    }
    ?>
    The above is taken from the first example.

  • #9
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Alright, I'll try it when I get some time, thanks.

    Nope, fsockopen does not work.
    Last edited by votter; 01-20-2010 at 08:46 PM.


  •  

    Posting Permissions

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