Page 1 of 1

Problem w/ fopen

Posted: Sat Jun 15, 2002 11:30 pm
by kevdude
Hello:

I'm having difficulties with the following. I'm using Windows 98 with the latest Apache and PHP:

if(!($myFile=fopen('http://www.fborfw.com/strip_fix/','r')))
{
echo "Sorry, the FBorFW strip is under maintenance.";
exit;
}

The following error is returned:

Warning: php_hostconnect: connect failed in c:\program
files\apache group\apache\htdocs\test1.php on line 14
Warning: fopen("http://www.fborfw.com/strip_fix/", "r") - Bad
file descriptor in c:\program files\apache
group\apache\htdocs\test1.php on line 14

The strange thing is, this works fine on Windows 2000. Anyone have any clues?

Thanks

Posted: Sun Jun 16, 2002 12:01 am
by fatal
Since your on localhost, use 'c:\ect...'' to get the file.

Posted: Sun Jun 16, 2002 6:43 am
by kevdude
Yes, I have no problem using fopen for local html files on my c drive. But I would like to grab a URL from a website (as in the example I gave), not a local file on my c drive.

(Typing in http://localhost/test1.php in my browser accesses c:\program files\apache group\apache\htdocs\test1.php.)

What is strange is that I'm able to open the html page from the website I want (referenced in my php code) on a Win2k machine with the same Apache and PHP configurations. Why would it behave differently on a Win98 machine?

INI

Posted: Sun Jun 16, 2002 7:06 pm
by phphead
in php.ini do you have allow url-fopen set to on

Posted: Sun Jun 16, 2002 7:17 pm
by kevdude
Yes, it's set as follows:
allow_url_fopen=On

Too

Posted: Tue Jul 16, 2002 6:17 am
by falco
I've got the same problem.

The allow_url_fopen is On.

The server's parameters:
Version: PHP 4.0.6
System: Linux porky.devel.redhat.com 2.4.18-0.1smp #1 SMP Wed Feb 27 07:25:23 EST 2002 i686 unknown
WEB-Server: Apache 1.3.22

It seems to be a bug? :cry:

Posted: Tue Jul 16, 2002 6:50 am
by Wayne

Code: Select all

if(!($myFile=fopen('http://www.fborfw.com/strip_fix/','r')))
maybe Im missing something, but where is the file you are trying to open? I only see the directory path. Surely you wanted to mention a file after /strip_fix/ ??????

Posted: Tue Jul 16, 2002 6:57 am
by falco
:D

Yes, he really forgot the filename, but for me still don't works:

Code: Select all

$file = file('http://weather.noaa.gov/pub/data/observations/metar/stations/LHBP.TXT');
:(

When i try to open the file from a browser, I get it normally.

On FreeBSD

Posted: Tue Jul 23, 2002 5:27 pm
by musashi
I am sure that Falco's code is correct. His example works for me as follows:

Code: Select all

<?php
$file = file('http://weather.noaa.gov/pub/data/observations/metar/stations/LHBP.TXT');
print_r($file);
?>
I get back the array output from the LHBP.TXT file. I would suggest checking out the PHP setup in the php.ini file. It is possible it is a compiler problem, but it does work on FreeBSD using php v. 4.2.2