sdbindoff Posted July 5, 2007 Share Posted July 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 5, 2007 Author Share Posted July 5, 2007 Thanks for the reply frost, i have previously checked and the allow_url_fopen was set to On so thats one solution down ??? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 www.php.net/file_get_contents or www.php.net/file Did you try using those functions instead of fopen ? Also is fopen producing an error message? Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 5, 2007 Author Share Posted July 5, 2007 will try them functions now, but how do you check whether fopen is producing a error message? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 set www.php.net/error_reporting at the top of the page to E_ALL and make sure display_errors is on, if not set it on with ini_set at the top of the php page. Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 5, 2007 Author Share Posted July 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 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. Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 5, 2007 Author Share Posted July 5, 2007 Ive got to leave work now, thanks very much for your help frost, i will more than likely be back on tomorrow Regards Sam Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 10, 2007 Author Share Posted July 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 11, 2007 Author Share Posted July 11, 2007 anybody mind testing the code for me? <?php if ($fo = fopen("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml","r")) { echo '1'; } else { echo '2'; } ?> Im getting 2!? Quote Link to comment Share on other sites More sharing options...
sdbindoff Posted July 12, 2007 Author Share Posted July 12, 2007 can anybody please paste the code above and run it and post back what number they got? regards sam Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.