mercuryfenix Posted August 1, 2007 Share Posted August 1, 2007 trying to update an xml file from PHP....any help would be appreciated! it is supposed to open the outdated rss.xml and update it with the latest 6 entries from the table.... must be something wrong with the opening of the file...getting the error: Warning: fopen(rss.xml) [function.fopen]: failed to open stream: Permission denied in /home/mysiteinfo/public_html/mysiteinfo/rss/update_rss.php on line 31 can't open file <? ///////// Connect to the DB /////////////////////////////////////////// require_once('../mysql_connect.php'); ///////// Getting the data from Mysql table for first list box //////// $quer2=mysql_query("SELECT * FROM rss ORDER BY rss_id DESC LIMIT 0,6"); ///////// End of query for first list box ///////////////////////////// $body="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> <rss version=\"2.0\"> <channel> <title>My Site Name</title> <link>http://www.mysite.com</link> <description>my site description</description> <copyright>(c) 2007, mysite.com. All rights reserved.</copyright> "; while($nt = mysql_fetch_array($quer2)) { $body .=" <item> <title>$nt[title]</title> <link>$nt[link]</link> <description>$nt[description]</description> <pubDate>$nt[pubdate]</pubDate> </item>"; } $body .=" </channel> </rss>"; echo $body; $path="rss.xml"; $file_name=fopen($path,"w") or die("can't open file"); fwrite($file_name,$body); fclose($file_name); ?> Quote Link to comment https://forums.phpfreaks.com/topic/62926-fwrite-problems/ Share on other sites More sharing options...
lur Posted August 1, 2007 Share Posted August 1, 2007 There's probably nothing wrong with your code, failed to open stream: Permission denied Change the permissions on the file. http://www.dartmouth.edu/~rc/help/faq/permissions.html http://en.wikipedia.org/wiki/Chmod Quote Link to comment https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313299 Share on other sites More sharing options...
mercuryfenix Posted August 1, 2007 Author Share Posted August 1, 2007 I use a shared hosting service online to host the site that this is on....is there a security vulnerability that could cause them to disallow fwrite() on my server? I have checked the permissions and they appear to be right to me. Quote Link to comment https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313310 Share on other sites More sharing options...
mercuryfenix Posted August 1, 2007 Author Share Posted August 1, 2007 hmm ok so I scanned through the permissions links posted above...how do I implement a permissions change? from what I gather I need to do something with $ chmod [references][operator][modes] file1 ... and to give a user named mercuryfenix read and write permissions... $ chmod u+rw rss what do I do with this? ??? sorry if this is a nub question! Quote Link to comment https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313329 Share on other sites More sharing options...
mercuryfenix Posted August 1, 2007 Author Share Posted August 1, 2007 ok so i got this far...still getting an error Parse error: syntax error, unexpected T_STRING with this code...this is just the bottom part of the code from above but modified slightly....i dont understand chmod fully; $body .=" </channel> </rss>"; echo $body; $path="rss.xml"; chmod u+rw rss; $file_name=fopen($path,"w") or die("can't open file"); fwrite($file_name,$body); fclose($file_name); chmod u-rw rss; ?> Quote Link to comment https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313343 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.