So I changed it a bit and get this error:
Invalid query: No database selected
Whole query: SELECT * FROM blog ORDER BY idblog DESC LIMIT 10
Here is the new code. Anyone got any ideas? The Connections/Conn.php is the correct path and is used on other pages to connect just fine to the database. I just don't know why this won't work.
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
// Set RSS version.
echo "
<rss version=\"2.0\">";
// Start the XML.
echo "
<channel>
<title>Momma Talk</title>
<description>Momma talk for expectant mothers, experienced mothers and all mothers in between!</description>
<link>http://www.ecochicmomma.com/mommatalk_detail.php</link>";
// Create a connection to your database.
require("Connections/Conn.php");
// Query database and select the last 10 entries.
$query = sprintf("SELECT * FROM blog ORDER BY idblog DESC LIMIT 10");
$data = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$data) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while($row = mysql_fetch_array($data))
{
// Convert database images data into actual image link.
$row[entry] = str_replace("images/", "http://www.ecochicmomma.com/images/", $row[entry]);
// Continue with the 10 items to be included in the <item> section of the XML.
echo "
<item>
<link>http://www.ecochicmomma.com/mommatalk_detail.php?ID=".$row[idblog]."</link>
<guid isPermaLink=\"true\">http://www.ecochicmomma.com/mommatalk_detail.php?ID=".$row[idblog]."</guid>
<title>".$row[subject]."</title>
<description><![CDATA[".substr($row[entry],0,250)."]]></description>
<comments>http://www.ecochicmomma.com/mommatalk_detail.php?ID=".$row[id]."#Comments</comments>
</item>";
}
// substr can limit the number of characters. First number is starting point while the second number is number of characters.
// otherwise just use $row[entry].
// <guid> is an optional sub-element of <item> but recommended if you don’t want to receive a warning when validating your RSS.
echo "
</channel>
</rss>";
?>