Jump to content

fwrite() problems


mercuryfenix

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/62926-fwrite-problems/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313329
Share on other sites

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;
?>

Link to comment
https://forums.phpfreaks.com/topic/62926-fwrite-problems/#findComment-313343
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.