Cannot open any file using fopen() when specifying url.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Cannot open any file using fopen() when specifying url.

Postby ssinghal66 » 13. June 2008 05:07

I am trying to run a simple script such as:

$url='http://localhost/xampp/index.php';
//$url='c:\xampp\htdocs\index.php';
if (fopen ($url,"r"))
{
echo "It exists !!";
}
else
{
echo "It does not exist !!";
}

Error I get is :

[message] => fopen(http://localhost/xampp/index.php): 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.

If I replace the url with 'c:\xampp\htdocs\index.php' it works fine.

Please help. Already spent one whole day on this.
ssinghal66
 
Posts: 2
Joined: 13. June 2008 04:56

Postby Wiedmann » 13. June 2008 11:18

Try '127.0.0.1' instead of 'localhost' in the uri.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Thanks. That worked.

Postby ssinghal66 » 13. June 2008 19:46

But why does the 'localhost' not get resolved to that ip address. Just a thought. Thanks again.
ssinghal66
 
Posts: 2
Joined: 13. June 2008 04:56

Postby Wiedmann » 13. June 2008 20:13

But why does the 'localhost' not get resolved to that ip address.

The problem is an other:
With "localhost" PHP want access the server with IPv6. But Apache don't understand IPv6. With "127.0.0.1" IPv4 is used.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 55 guests