sweety
03-19-2009, 02:44 PM
Hello everybody,
I wrote a php code for dynamically creating xml when MYSQL database is updated. When I run the code it is not updating the xml file.
The code worked fine until March 2, the day of our server switch. I dont know wht to do. Any help is greatly appreciated. Thank you.
<?
header("Location:rss.xml");
mysql_select_db("news", $connection);
$select = "SELECT ID, headline, cutline FROM newsstory where active = 0 ORDER BY dtadded DESC LIMIT 5";
$query = mysql_query($select) or die(mysql_error());
$file = fopen("rss.xml", "w+");
fwrite($file, "<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet title='XSL_formatting' type='text/xsl' href='rss.xsl'?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>ISU NEWS</title>
<link>http://www.indstate.edu/news/</link>
<description>News and Releases from Indiana State University</description>
<language>en-en</language>");
while($array = mysql_fetch_array($query)){
extract($array);
$headline = htmlentities($headline);
$headline = stripslashes($headline);
$cutline = htmlentities($cutline);
$cutline = stripslashes($cutline);
$file = fopen("rss.xml", "w");
fwrite($file, "<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet title='XSL_formatting' type='text/xsl' href='rss.xsl'?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<item>
<title>$headline</title>
<link>http://www.indstate.edu/news/news.php?newsid=$ID</link>
<description>$cutline</description>
<guid>http://www.indstate.edu/news/news.php?newsid=$ID</guid>
</item>");
}
//end of while loop
fwrite($file,"</channel></rss>");
fclose($file);
?>
I wrote a php code for dynamically creating xml when MYSQL database is updated. When I run the code it is not updating the xml file.
The code worked fine until March 2, the day of our server switch. I dont know wht to do. Any help is greatly appreciated. Thank you.
<?
header("Location:rss.xml");
mysql_select_db("news", $connection);
$select = "SELECT ID, headline, cutline FROM newsstory where active = 0 ORDER BY dtadded DESC LIMIT 5";
$query = mysql_query($select) or die(mysql_error());
$file = fopen("rss.xml", "w+");
fwrite($file, "<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet title='XSL_formatting' type='text/xsl' href='rss.xsl'?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>ISU NEWS</title>
<link>http://www.indstate.edu/news/</link>
<description>News and Releases from Indiana State University</description>
<language>en-en</language>");
while($array = mysql_fetch_array($query)){
extract($array);
$headline = htmlentities($headline);
$headline = stripslashes($headline);
$cutline = htmlentities($cutline);
$cutline = stripslashes($cutline);
$file = fopen("rss.xml", "w");
fwrite($file, "<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet title='XSL_formatting' type='text/xsl' href='rss.xsl'?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<item>
<title>$headline</title>
<link>http://www.indstate.edu/news/news.php?newsid=$ID</link>
<description>$cutline</description>
<guid>http://www.indstate.edu/news/news.php?newsid=$ID</guid>
</item>");
}
//end of while loop
fwrite($file,"</channel></rss>");
fclose($file);
?>