View Full Version : Help Me Fix My RSS Feed

Joseph Witchard
06-13-2009, 08:10 AM
I built it with PHP, but the problem seems to be XML related. That's why I'm posting it here. This is my first attempt at an RSS feed, so go easy on me. I was able to bookmark the feed in Firefox, but when you go to the bookmark, it says "Live bookmark feed failed to load."


/** Coded by: Jeffrey (Joseph Witchard)
** Created on: 06/13/09
** Last modified: 06/13/09
** Purpose: To syndicate Rebirth news
** via RSS. */

// configure to XML

header("Content-Type: application/xml; charset=utf-8");

// include the connection setting


// set up the connection

$conn = access_function();

// set up the query

$query = "SELECT post_id, author_name, DATE_FORMAT(date_posted, '%W, %M %d, %Y %l:%i %p') AS formatted_date, author_email, description, a.category_id, c.category_name, title FROM posts a INNER JOIN categories c ON a.category_id = c.category_id ORDER BY post_id LIMIT 10";

// start pulling out the data

if ($stmt = $conn->prepare($query))


$stmt->bind_result($postID, $author, $date, $email, $post_desc, $cat_id, $cat_name, $post_title);

echo '<?xml version="1.0"?>';

echo '<rss version="2.0">';

echo "<channel>";

while ($stmt->fecth())

echo "<item>";

echo "<title>$post_title</title";

echo "<link>http://www.uhrebirth.com/show_news/$postID</link>";

echo "<description>$post_desc</description>";

echo "<pubDate>$date</pubDate>";

echo "<author>$author</author>";

echo "<managingEditor>$email</managingEditor>";

echo "<webMaster>josephwitchard@uhrebirth.com</webMaster>";

echo "<category>$cat_name</category>";

echo "</item>";


echo "</channel>";

echo "</rss>";

echo "</xml>";



** I got it working. Aside from all of the syntax errors, I didn't realize that XML tags were messing it up; I assumed they would be required. Now I need to know how to add a title to it, because when I bookmark the feed now, the default title is http://www.uhrebirth.com/rss.php (the URL to the feed).