Jump to content

fopen fails to open localhost


topcoder1

Recommended Posts

I'm trying to use fopen another url, it doesn't work on localhost, however it works on other domains(such as google.com).  The localhost url is valid.

I have tried both fopen and file_get_contents.  the php page simply hangs and says:

PHP Warning:  fopen(http://localhost/) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\r\n in D:\\Program Files\\Apache Group\\Apache2\\htdocs\\myapp\\callurl.php on line 3

[Thu Apr 30 14:43:22 2009] [error] [client 127.0.0.1] PHP Fatal error:  Maximum execution time of 30 seconds exceeded

 

callurl.php:

<?php

//$content = file_get_contents("http://localhost/myapp/test.php");

$handle = fopen("http://localhost/", "r");

$contents = '';

while (!feof($handle)) {

  $contents .= fread($handle, 8192);

 

}

fclose($handle);

echo($contents);

?>

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.