can't retrieve data from the net with file_get_contents ?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    #1

    can't retrieve data from the net with file_get_contents ?!

    for some reason i keep getting :

    Warning: file_get_conten ts(): php_network_get addresses: getaddrinfo failed:
    Temporary failure in name resolution in
    /home/rob/www/php/filegetcontents 2.php on line 3

    Warning:
    file_get_conten ts(http://folding.stanford.edu/teamstats/team92.txt): failed
    to open stream: Resource temporarily unavailable in
    /home/rob/www/php/filegetcontents 2.php on line 3

    when trying to retrieve a page of text (stats for a distributed computing
    project) from the Net like this :

    $personal =
    file_get_conten ts("http://folding.stanfor d.edu/teamstats/team92.txt");

    i also tried implode/file ... same error.
    but when i fill in the URL in Mozilla it is retrieved just fine and no
    'temporary failures' at all ?!

    what could be going wrong with the name resolution ??
  • Nikolai Chuvakhin

    #2
    Re: can't retrieve data from the net with file_get_conten ts ?!

    Rob <unknown@anonym ous.net> wrote in message
    news:<vu9jfs9l9 7mid2@corp.supe rnews.com>...[color=blue]
    >
    > when trying to retrieve a page of text (stats for a distributed computing
    > project) from the Net like this :
    >
    > $personal =
    > file_get_conten ts("http://folding.stanfor d.edu/teamstats/team92.txt");
    >
    > i also tried implode/file ... same error.
    > but when i fill in the URL in Mozilla it is retrieved just fine and no
    > 'temporary failures' at all ?!
    >
    > what could be going wrong with the name resolution ??[/color]

    Nothing. Most likely, it's not name resolution at all. Try this:

    $host = 'folding.stanfo rd.edu';
    $path = 'teamstats/team92.txt';
    $fp = fsockopen ($host, '80');
    if ($fp) {
    fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n") ;
    } else {
    die ('Oops... Nobody home...');
    }
    $data = '';
    while (!feof ($fp)) {
    $data .= fgets ($fp, 10240);
    }
    fclose ($fp);
    echo '<pre>', $data, '</pre>';

    Cheers,
    NC

    Comment

    • Rob

      #3
      Re: can't retrieve data from the net with file_get_conten ts ?!

      On 21 Dec 2003 00:11:23 -0800, (Nikolai Chuvakhin) wrote:
      [color=blue][color=green]
      >> what could be going wrong with the name resolution ??[/color]
      >
      > Nothing. Most likely, it's not name resolution at all.[/color]

      then what could it be ??
      the 'funny' thing is that when i run the code in PHP4.3.1 on Windows2000, it
      works OK !!
      but the same code in PHP4.3.3 in Linux (Mandrake 9.2) gives me the name
      resolution errors ?!
      [color=blue]
      > Try this:
      >
      >$host = 'folding.stanfo rd.edu';
      >$path = 'teamstats/team92.txt';
      >$fp = fsockopen ($host, '80');
      >if ($fp) {
      > fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n") ;
      >} else {
      > die ('Oops... Nobody home...');
      >}
      >$data = '';
      >while (!feof ($fp)) {
      > $data .= fgets ($fp, 10240);
      >}
      >fclose ($fp);
      >echo '<pre>', $data, '</pre>';[/color]

      Ok, i'll boot back into Linux later and try it !!

      thanks !

      --
      Rob

      Comment

      Working...