vista localhost and php fopen
Posted by: mikejf12 (---.range81-129.btcentralplus.com)
Date: December 09, 2007 09:32PM

Hi

I have a new dell machine with vista installed. Ive just installed the latest wamp download onto it. However, my php code cannot fopen http type paths using fopen.

Ive installed wamp on xp previously ad had no problems. i.e.

c:/wamp/www/theme/b1/template/indexmn.htm -- success
http : / / localhost/theme/b1/template/indexmn.htm -- failure under vista

Ive checked the php.ini wapper settings i.e.

allow_url_fopen = On

Im not sure what else might need to be configured and I wondered whether anyone else has hit the same issue ?



Edited 2 time(s). Last edit at 12/10/2007 09:47PM by mikejf12.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: mikejf12 (---.range81-129.btcentralplus.com)
Date: December 10, 2007 09:49PM

I found a way around this by using paths like

theme/b1/template/indexmn.htm

under localhost. But this is annoying because I just want to be abe to port code directly from wamp on xp tp wamp on vista.They dont act in the same way.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: yfastud (Moderator)
Date: December 10, 2007 10:29PM


Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: mikejf12 (---.range81-129.btcentralplus.com)
Date: December 11, 2007 08:01PM

what i mean is that a php fopen statement fails for a path string that starts with http and refers to a file on the local host. Replacing that same file string with a path starting c: suceeds. i.e.

fopen ("c:/wamp/www/theme/b1/template/indexmn.htm", "rb" );
fopen( "http : / / localhost/theme/b1/template/indexmn.htm","rb"winking smiley;

my code worked on wamp under xp but not on vista. If I change the path to

theme/b1/template/indexmn.htm

my code can open the file. I just wondered what might cause a time out when fopen tries to open a file path that includes loalhost.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: mikejf12 (---.range86-146.btcentralplus.com)
Date: December 17, 2007 09:48PM

Im still having trouble with a php fopen statement timing out when trying to open a url on the localhost (above). However, I tried replacing my fopen statements with fsockopen in order to set a timeout and try and get more error information. What I got was the error

Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?

using the php info function to check my php set up I get

Registered PHP Streams php, file, data, http, ftp, compress.zlib

so it seems that I dont have a wrapper for http .. how do I enable one ?

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: tcase (---.chi01.dsl-w.verizon.net)
Date: December 18, 2007 05:52AM

actually, what it is also when you use something like include "[address.com];;
so it includes something into a webpage,, every forums ive been to had said the same thing, you have to turn on allow_url_fopen. I had this same problem with vertrigo webserver which I liked very much, but couldnt even get registered into the forums because they are either too busy, or dont care anymore... anyhow,, it used to be allow_url_include = On, but now its the fopen = On for doing this,,, but with all servers ive found that are wamp, they tend to always have it on... So, now we need to find out why its still not working,,, its like its still turned off, I am having same problem, and I still cant figure out why, this is why I tried WAMP 2.0 other than Vertrigo web server, which again is my favorite, no offense,,, but not anymore since getting help is slim to none, customer service is a main factor when developing software...lol.. was hoping to get it here...

with allow_url_fopen = On, and when you use fopen, or include, it still dont work like its off.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: mikejf12 (---.range86-146.btcentralplus.com)
Date: December 26, 2007 11:53AM

I still have not managed solve this, to sum it up the http wrapper does not work in wampserver 2.0 on vista, even though phpinfo shows that it is enabled. I understand that there is a similar issue with install shield and vista. What tool is used by wamp to install ?

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: mikejf12 (---.range86-146.btcentralplus.com)
Date: January 02, 2008 09:16PM

Still have not managed to solve this error .. Ive investigated a few suggestions and can confirm what it is not

* It is not an ip6 issue. someone told me that it was related to the ip6 entry in the windows hosts file i.e.
::localhost. Tried removing and bouncing wamp - no good

* It is not related to apache aliases. i.e. it is not necessary to create aliases for directories under c:\wamp\www

* It is not related to php.ini entry allow_url_fopen

* it is not related to safe mode as that is not enabled.

It does seem to be related to the 64 bit version of wampserver running on vista 64. It seems that the wrappers like http are not enabled even though config files say they are. There are no errors in the apache log files.

THis is where wamp fails because there is no way to solve these issues.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: anarchitecton (89.152.241.---)
Date: February 27, 2008 12:41AM

Any success in solving this issue? I've recently 'stumbled' on this problem and haven't been able to find a solution.

Thanks in advance.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: anarchitecton (---.cpe.netcabo.pt)
Date: February 27, 2008 01:11AM

wow,

I think I just found the solution here: [bugs.php.net]

It seems by changing 'localhost' to '127.0.0.1' it works!

Here's a reference to the issue, "Binding to localhost throws exception":
[msdn2.microsoft.com]

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: chris_f (---.in-addr.btopenworld.com)
Date: February 29, 2008 11:50AM

I've had this issue, I narrowed it down to using spybot search and destroy. If you have the full immunization setup, it adds a lot of localhost redirects for dodgy website domains. I stripped all of these out and left only 127.0.0.1 localhost in it. Restarted all services and everything started working as it should.

Might be worth checking.

Chris F

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: swc43 (---.cable.ubr12.newt.blueyonder.co.uk)
Date: March 27, 2008 04:43PM

anarchitecton Wrote:
-------------------------------------------------------
> wow,
>
> I think I just found the solution here:
> [bugs.php.net]
>
> It seems by changing 'localhost' to '127.0.0.1' it
> works!


I can verify the above worked for me after having the same problem on moving from xp (sp2) to vista.

Thanks for saving me yet one more vista headache!!

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: RaulKing (---.w82-123.abo.wanadoo.fr)
Date: February 06, 2009 08:08PM

I seem to have the same problem as Mikejf12 every time my code refers to [localhost] when my script invokes :

includes(), file(),file_get_contents... I get the php message "couldn't open filename at line 64"

It was working fine under XP and I checked and tested every bit of php.ini and Apache conf file paths.

It works fine when I change my include or file_get_contents filenames to relative paths. But this cannot be a good solution in my case. I haven't yet solved this problem. It is logically unrelated to the 127.0.0.1 declaration that you mention above.

Note also :

A simple command on a page like ' include("[localhost]winking smiley; ' works fine.
However, it doesn't work anymore on a specific website; The only specific thing that website has are frames !

What can user side frames to do with server side php ?

At this point, I'm stuck.

Options: ReplyQuote
Re: vista localhost and php fopen
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 06, 2009 08:15PM

if you need to include a file then you shouldnt use localhost or 127.0.01

just use the filename for the folder you are in or using ../ and ./ and / to go up and down folders.


localhost will break scripts on other servers.



hope u understand?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Vista, include, fopen, file, file_get_contents ...etc.
Posted by: RaulKing (---.w82-123.abo.wanadoo.fr)
Date: February 08, 2009 04:22PM

Thanks for your comment, but I strongly disagree since my localhost server serves to test, develop and simulate and should remain as similar to the production environment as possible. And there are quite a few cases when the command include is required with http:// and not relative path.

Here are some important behavioral differences between

include("[website]winking smiley

and

include("PathUnder/page.ext"winking smiley

as you may see in the Php documentation. One of these differences is the value that vars declared in the i"ncluded file" may take.


Take a simple example : Your included file refers to var $_server[host] : Whether this var is determined in the included file, or the including file, or even a subincluded file (file included by an included file), the outcome can be different.


Other example (php doc) :
include 'http://www.example.com/file.php?foo=1&bar=2';//works
followed by
$foo=$_GET[foo];
$bar=$_GET[bar];

is equivalent to

$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.

As you can guess, your included file $foo var can get mixed up with an including file var. There are many applications of this, which I have thoroughly tested.

----


Coming back to my Wamp-Vista installation problem :


I have figured out that the frames had nothing to do with it. It is just that the loading of the frames was slowed down while waiting for the timeout of 60 seconds. (if no frames reload, implying that the page must be loaded first, which could only happen after the timeout)


So, I have carefully replaced over 13000 occurences of the string "localhost" (I administer many websites) in my php programs by "127.0.0.1". All seem to work fine now; But, I am not happy with this solution.

What comes to my mind is that it should be possible to force Vista to understand that 127.0.0.1 is equivalent to localhost, no matter what the setting is.

But this goes beyond my comptetency and I find the Vista network setup and management just hard to understand. So, I 'll keep listening to this thread hoping someone will come up with an answer.


Thanks

See my <a href="[games.nostradamila.com] games</a>

Options: ReplyQuote


Sorry, only registered users may post in this forum.