Jump to content

Error with file_get_contents and fopen


DragonWarden

Recommended Posts

I used fopen and file_get_contents to fetch the contents of a URL with no problems on my webhoster's site, which runs PHP 4.4.2 with Apache 1.3.34 (Unix). I then set up (for the first time) a home server (Windows XP64) running PHP 5.1.2 with Apache 2.0.55. When I try to retrieve the page [a href=\"http://www.google.com\" target=\"_blank\"]http://www.google.com[/a] using either function on my home server, I get the following errors (with the appropriate function name substituted):

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\apache\Apache2\htdocs\CD\index.php on line 33

Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: No error in C:\apache\Apache2\htdocs\CD\index.php on line 33

When I make the attempt on my webhoster's site, it works without problems. I have made sure that allow_url_fopen in php.ini is enabled, as some google searches had suggested. I have also tried fiddling with the user_agent field as some suggested that Apache's rejecting the request somehow due to that, but I have not been successful in banishing the warning. Does anyone have any other suggestions?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.