Forum Moderators: coopster

Message Too Old, No Replies

Real problem is fopen() returning blank page

         

Simone100

9:25 pm on Sep 24, 2006 (gmt 0)

10+ Year Member



Hi, found out I need to use fopen to open a url on a different
server, but when I do it only returns a blank page. No error messages
and no url.

fopen is turned on in php.ini.

Please let me know why this is happening, thanks!

ahmedtheking

9:36 pm on Sep 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, you can also use file() too!

Right, this may be caused by a few things:

You see, PHP doesn't send a 'main' user-agent stamp when it opens urls through file and fopen. This may be causing the blank page because some sites block the non-browser opening of their pages!

Have a read of this PHP.net example:

[uk2.php.net...]

barns101

7:01 pm on Sep 25, 2006 (gmt 0)

10+ Year Member



Your host could have a firewall to block outbound connections (but in that case you should get an error message).

eelixduppy

7:23 pm on Sep 25, 2006 (gmt 0)



Add error_reporting [us2.php.net](E_ALL); to the top of your script to see if there are any problems. Also, you said "fopen is turned on in php.ini.". Does this mean that you have allow_url_fopen [us2.php.net] enabled? Check both of these things first.

Good luck!

phparion

12:07 pm on Sep 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you may want to have a look at cURL www.php.net/curl it is much better to use cURL in many cases than fopen :) ... i have noticed sometimes HOSTs block use of fopen but allow to use cURL ..