tags:

views:

938

answers:

3
$file = @fopen("http://ajax.htm","rb");

I am getting this error while using fopen

Warning: fopen(xyz.htm): failed to open stream: HTTP request failed! 
in /home/user/public_html/aaa/ttt.php on line 8

what could be the reason behind this?

+1  A: 

from docs:

If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

edit: ajax.htm is not a valid url.

SilentGhost
allow_url_fopen is enabled here....i dont think that this error is because of allow_url_fopen coz this code of mine was not giving any error utill now but suddenly gave this error today.....
developer
may be you could remove @ to see more?
SilentGhost
i have fixed the problem.The original url that i was reading was having error and this code couldnt read that. :-)...thnx all for your help...
developer
A: 
$file = @fopen("ajax.htm","rb");

there is your problem i think

http://nl3.php.net/function.fopen

x4tje
huh? "Note: For portability, it is strongly recommended that you always use the 'b' flag when opening files with fopen(). "
SilentGhost
yes you are right....'b' is always strongly recommended and i dont think it gives any kinda error.
developer
+4  A: 

I am going to go out on a huge limb here and suggest the problem is the url, 'http://ajax.htm'.

Jeff Ober