I have a real simple script that runs some queries to generate an RSS formatted XML file. It was working perfectly fine and then all of a sudden I get this below error:
CODE
Warning: fopen(xml/rss1.xml): failed to open stream: Permission denied in /home/shmohel/public_html/rss.php on line 2
Warning: fwrite(): supplied argument is not a valid stream resource in /home/shmohel/public_html/rss.php on line 23
Warning: fclose(): supplied argument is not a valid stream resource in /home/shmohel/public_html/rss.php on line 24
Warning: fwrite(): supplied argument is not a valid stream resource in /home/shmohel/public_html/rss.php on line 23
Warning: fclose(): supplied argument is not a valid stream resource in /home/shmohel/public_html/rss.php on line 24
Here is the entirety of the script, only about 25 lines:
CODE
<?php
$file= fopen("xml/rss1.xml", "w"); #This is line 2
$rss.='<?xml version="1.0" encoding="ISO-8859-1"?>';
$rss.="<rss version='2.0'>";
$rss.="<channel>";
$rss.="<title>10 Newest Recipes - Recipe Tavern</title>";
$rss.="<description>A list of the 10 most recently submitted recipes at the Recipe Tavern.</description>";
$rss.="<link>http://www.recipetavern.com</link>";
mysql_connect ("localhost", "*****", "*****") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("*****");
mysql_select_db ("*****");
$sql=mysql_query("SELECT r.recipeid,r.recipename,r.desc FROM *****.`recipe` AS r JOIN *****.`beer_members` AS m ON r.memberid=m.id ORDER BY dateadded desc LIMIT 10;") or die(mysql_error());
while($rec=mysql_fetch_assoc($sql)){
$rss.="<item>";
$rss.="<title>".$rec['recipename']."</title>";
$rss.="<description><![CDATA[".$rec['desc']."]]></description>";
$rss.="<link><![CDATA[http://www.recipetavern.com/index.php?pg=recipe&recipeid=".$rec['recipeid']."]]></link>";
$rss.="<guid isPermaLink='false'>recipetavern_recipeid_".$rec['recipeid']."</guid>";
$rss.="</item>";
}
$rss.="</channel>";
$rss.="</rss>";
fwrite($file, $rss); #This is line 23
fclose($file); #This is line 24
?>
$file= fopen("xml/rss1.xml", "w"); #This is line 2
$rss.='<?xml version="1.0" encoding="ISO-8859-1"?>';
$rss.="<rss version='2.0'>";
$rss.="<channel>";
$rss.="<title>10 Newest Recipes - Recipe Tavern</title>";
$rss.="<description>A list of the 10 most recently submitted recipes at the Recipe Tavern.</description>";
$rss.="<link>http://www.recipetavern.com</link>";
mysql_connect ("localhost", "*****", "*****") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("*****");
mysql_select_db ("*****");
$sql=mysql_query("SELECT r.recipeid,r.recipename,r.desc FROM *****.`recipe` AS r JOIN *****.`beer_members` AS m ON r.memberid=m.id ORDER BY dateadded desc LIMIT 10;") or die(mysql_error());
while($rec=mysql_fetch_assoc($sql)){
$rss.="<item>";
$rss.="<title>".$rec['recipename']."</title>";
$rss.="<description><![CDATA[".$rec['desc']."]]></description>";
$rss.="<link><![CDATA[http://www.recipetavern.com/index.php?pg=recipe&recipeid=".$rec['recipeid']."]]></link>";
$rss.="<guid isPermaLink='false'>recipetavern_recipeid_".$rec['recipeid']."</guid>";
$rss.="</item>";
}
$rss.="</channel>";
$rss.="</rss>";
fwrite($file, $rss); #This is line 23
fclose($file); #This is line 24
?>
I tried playing around with the permissions of the XML file and nothing seemed to work, so I don't think it is a permissioning error. Does anyone here see any blatant mistakes in this code? Am I missing something?