Jump to content

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

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.