|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-05-23 11:58 UTC] pat at mail dot rit dot edu
I've seen this issue posted here a few times, and I think my problem is similar to Bug id #7880. fopen(), fsockopen(), and file() will not work with URL or IP address parameters. include() has the same issue. I believe it has something to do with getaddrinfo. Before upgrading to PHP4, I was running 3.0.16 and all of these functions were working perfectly with URL parameters. My configure script looks like this: ./configure --with-apache=/usr/temp/apache_1.3.19 --with-mysql=/usr/local --enable-track-vars --with-xml --with-openssl=/usr/local/ssl My php.ini DOES contain the line "allow_url_fopen = On" The fopen() script looks like this: $fd = fopen( "http://www.php.net/", "r" ); if( !$fd ) { echo "Cannot open URL"; } else { while ( !feof( $fd ) ) { $buffer = fgets( $fd, 4096 ); echo $buffer; } fclose ( $fd ); } and produces this output: Warning: php_network_getaddresses: getaddrinfo failed: name or service is not known in /var/www/patrickhaney.com/www/weather/test.php on line 24 Warning: fopen("http://www.php.net/","r") - Bad file descriptor in /var/www/patrickhaney.com/www/weather/test.php on line 24 Cannot open URL and yes, I can resolve php.net to 208.247.106.187. Using the IP address in place of the hostname produces the same output. If I use the fsockopen() function with this script: fsockopen("http://www.php.net/", 80, &$errno, &$errstr, 30); if(!$fp) { echo "Error: $errstr ($errno)<br>\n"; } else { fputs($fp,"GET / HTTP/1.0\n\n"); while(!feof($fp)) { echo fgets($fp,128); } fclose($fp); } I get this output: Error: (0) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
hello, my php is PHP Version 4.3.4 i've exatctly the same problem. my server isn't conected by dialup, and i got ever the message "php_network_getaddresses: getaddrinfo failed" when i use this line: fsockopen ("dummy_ip", 25, &$errno, &$errstr, 10) it didn't occurs with older versions of php. this IS NOT a server problem, is a problem of PHP, you only need tho make a search at google http://www.google.es/search?hl=es&ie=UTF-8&oe=UTF-8&q=php+php_network_getaddresses%3A+getaddrinfo+failed&meta= target "php_network_getaddresses: getaddrinfo failed" and see results, a lot of people get the same errors. i hope you found a solution for this :)I had the same problem as pat at mail dot rit dot edu using fsockopen(). He/she uses: fsockopen("http://www.php.net/", 80, &$errno, &$errstr, 30); But you shouldn't use 'http://' in the server name part. So use this instead. fsockopen("www.php.net", 80, &$errno, &$errstr, 30); Maybe this will not solve everybodies problem, but it sure solved mine.I am having the same problem .. I am using XAMPP 2.5 version ... it did work for me on the last version .... I am using the youtube API to receive youtube videos ... there is a major change in my case Message: Unable to Connect to tcp://gdata.youtube.com:80. Error #0: php_network_getaddresses: getaddrinfo failed: No such host is known. the return says it tries with TCP rather then http , but my actual stack trace says it is HTTP . #0 C:\xampp\php\PEAR\Zend\Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'http://gdata.yo...', Array, NULL, NULL, NULL) Does anyone have a clue what is wrong ???Confirmed this is a problem in my Php 5.3.13 install. With the following line: file_get_contents("www.google.com"); If I run it in the command line, it works fine. If I run it through apache I get the getaddrinfo failed error. I am using Arch Linux, Kernel 3.3.7. My temporary work around is to do a full stop and start of Apache. Restarting the service does not solve the problem.