Click to See Complete Forum and Search --> : fopen() a remote url


Anon
01-03-2001, 01:24 PM
I haven't been able to retrieve a remote file for a news headline.

I have:
apache 1.3.14
mysql 3.22.32
php 4.0.4
slackware 7.1 and a 2.2.18 kernel

php fails to return a file handle, i.e.

$fp = fopen($url, "r");

It returns a file handle number for a local file, but it fails to return a number if the url has "http://" included in the url, i.e. http://phpnuke.com/backend.php.

Should it work by default or could I have missed including support to do it?
Is there something obvious or not so obvious?
I've tried several home brewed tests, and I've read a lot, but I am in need of any help or suggestions.

Anon
01-03-2001, 02:04 PM
Are you sure that $url contains what you think it contains?
Are you behind a firewall? do you need to use a proxy?

Anon
01-03-2001, 08:28 PM
Yes, they contain urls from a database in a news portal program called PHP-Nuke.

One of the tests I did was to use the url in the location window of my browser and it did retrieve a page that I downloaded and looked at. It was headlines.

I am behind a linux masq'd and ipchains firewall of my own creation, behind the same one I retrieved the page with the browser with.

The error I get is during the execution of the php script, saying that script line returned a "bad file descriptor". The request for the file is aborted on the statement, $fp = fopen($url, "r");. The variable $fp is not processed. This fails before a request is sent.

Thanks, I'm still going to work on it, any more ideas.

vincente
01-04-2001, 05:38 AM
$fp is filled with a "false" only if the $url could not be opened.

That means that

a) $url does not contain a correct URL. You can check that by putting "echo $URL;" right before the fopen line.

b) The URL cannot be retreivedb because there is something blookcing the request.

Show us some more of your code and maybe we can find some other error in it.