Click to See Complete Forum and Search --> : Help with Dynamic RSS Code


madddidley
08-09-2005, 10:22 AM
I have this page and for some reason I get an error that says

The following tags were not closed: rss, channel, item.


Any help would be appreciated...

Thank,
maddDidley.com


<?php

//error_reporting(E_ALL^E_NOTICE);
mysql_connect("localhost");
mysql_select_db("madddidley");


// Let us first make sure the php file is
// interpeted as xml information

header ("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";

// SQL connection
$query = "SELECT * FROM posts ORDER BY post_id DESC";
$go = mysql_query($query);
$num = mysql_num_rows($go);
echo mysql_error();

if($num == 0)
{
exit;
}
else
{
// First we print the overall xml information
echo "<rss version=\"2.0\">";
echo "<channel>";
// Here comes the global title for you rss
echo "<title>maddnews</title>";
// Here comes the url for the page that the rss applies for
echo "<link>http://www.maddDidley.com/</link>";
// Here comes a short description of the page
echo "<description>maddDidley's Blog Newsfeed</description>";

// Now over to the dynamic part

while($a=mysql_fetch_object($go)) {
//$blog_title = stripslashes($sql->title);
//$blog_link = "blog.php?ID=".$sql->id;
//$blog_description = stripslashes($sql->header);

echo "<item>";
echo "<title>$a[ttitle]</title>";
echo "<link>http://www.maddDidley.com</link>";
echo "<description>";
echo "$a[comments]";
echo "</description>";
echo "</item>";
}

// And at last the closing tags for the overall info
echo "</channel>";
echo "</rss>";
}
?>

arto
08-09-2005, 02:28 PM
Well, this error message means there's something wrong with the code between opening <item> and closing </item> and that's why closing tags are missing.
Wild guess: since you use mysql_fetch_object, shouldn't it be $a->title instead of $a[title]

Arto

madddidley
08-10-2005, 04:38 PM
I finally figured it out. I'm at work so I can't post the code for any one who may want it. I'll put it up tonight.