Page 1 of 1

file(): php_network_getaddresses: getaddrinfo failed

Posted: Thu Aug 10, 2006 6:38 pm
by crossland
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


When I execute my script to read a xml feed, the following error is produced:

Code: Select all

Warning: file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in test.php on line 12

Warning: file(http://feeds.<domain>.co.uk/?bb14ed26-fdd2-491a-bef5-858ddbe5b58f): failed to open stream: Success in test.php on line 12

Warning: Invalid argument supplied for foreach() in test.php on line 15


However, if I refresh the page to re-execute the code, it will then work. Every time I refresh it alternates between error and working. The code is as follows:

Code: Select all

<?php
$lines = file('http://feeds.<domain>.co.uk/?bb14ed26-fdd2-491a-bef5-858ddbe5b58f');

foreach ($lines as $line_num => $line) {
  echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
 }

?>
Why would it work on the second execution, but not the first?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Aug 11, 2006 12:42 am
by RobertGonzalez
Maybe there is some form of validation that is taking place on one, but not the other. Or maybe their server is wonky.