Jump to content

fopen problem


sdbindoff

Recommended Posts

Hi

 

Im in the middle of creating a flash movie with various movie clips loading variables from a php file. The problem lies when i try and fopen and read an xml file from external webpages (ie. http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml) within my php file.

 

Have done numerous tests, one in particular was creating my own xml file and testin on the server:

 

1. Created xml file and upload it to the same directory as the php file

 

2. $fo = fopen("bbcrss.xml", "r"); returns true

 

3. $fo = fopen("http://www.mydomain.co.uk/bbcrss.xml", "r"); returns false

 

This is just one of many tests i have done but explains the problem in best detail.

 

Sam ;D

Link to comment
Share on other sites

www.php.net/fopen

 

allow_url_fopen I believe has to be set to on in the php.ini file or an .htaccess file or with www.php.net/ini_set  inside the php file.

 

PHP will check to make sure that allow_url_fopen is enabled

Link to comment
Share on other sites

i have set the error_reporting to E_ALL, the display_errors to 1 and the allow_url_fopen to 1 at the top of the file and it comes up with:

 

Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/memorial/public_html/xml/test.php on line 65

 

Warning: fopen(http://www.wallsendmemorialhall.co.uk/xml/bbcrss.xml): failed to open stream: Connection refused in /home/memorial/public_html/xml/test.php on line 65

Link to comment
Share on other sites

Sounds like your server is blocking outbound connections to other sites. Try the file and file_get_contents see if that works. If not see if www.php.net/CURL is installed on your server, if it is read through that and try using CURL to grab the data.

Link to comment
Share on other sites

So..........ive tried file and file_get_contents, no luck. CURL is installed on the server and i have tried the example code from www.php.net/CURL that writes a new text file to the server containing whatever was in the file stated, this is the code i used:

 

<?php

$ch = curl_init("http://www.google.co.uk/");
$fp = fopen("example.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

?>

 

and example.txt contains nothing.

 

The file and code i have been trying to get working using fopen is:

 

$fo = fopen("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml","r");

 

returns false, if anybody would like to give it a try and let me know if it works for you that would be great.

Link to comment
Share on other sites

can anybody please paste the code above and run it and post back what number they got?

 

regards sam

 

I think your SOL, your server blocked the remote reading of files. If you are on a shared server, chances are you cannot get them to change that either and init_set will not work.

 

BTW, the above returns 1 for me, but I also know my server allows me to read remote files.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.