Problem creating RSS feed from PHP/MySQL
I'm trying to create a simple RSS feed pulling info from my database. Any idea what's wrong? Any help would be great.
I'm getting this error:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache2\htdocs\ecochic\rss.php on line 17
This is line 17:
while($row = mysql_fetch_array($data))
This is the full code is:
<?php
header("Content-type: text/xml");
echo "<xml version=\"1.0\" encoding=\"UTF-8\">";
echo "
<rss version=\"2.0\">";
echo "
<channel>
<title>Feed title</title>
<description>A description of the feed contents</description>
<link>http://www.ecochicmomma.com/</link>";
require_once("Connections/Conn.php");
// Query database and select the last 10 entries.
$data = mysql_query("SELECT * FROM blog ORDER BY idblog DESC LIMIT 10");
while($row = mysql_fetch_array($data))
{
// Continue with the 10 items to be included in the <item> section of the XML.
echo "
<item>
<link>http://www.ecomchicmomma.com/mommatalk_detail.php?ID=".$row[id]."</link>
<guid isPermaLink=\"true\">http://www.ecochicmomma.com/mommatalk_detail.php?ID=".$row[id]."</guid>
<title>".$row[subject]."</title>
<description><![CDATA[".substr($row[entry],0,150)."]]></description>
<comments>http://www.ecochicmomma.com/mommatalk_detail.php?id=".$row[id]."#Comments</comments>
</item>";
}
echo "
</channel>
</rss>";
?>