RSS feed created with PHP only shows the title in the feed reader
Posted
by
James Simpson
on Stack Overflow
See other posts from Stack Overflow
or by James Simpson
Published on 2010-12-21T07:51:41Z
Indexed on
2010/12/21
7:54 UTC
Read the original article
Hit count: 394
I am using the following PHP code to generate the XML for an RSS feed, but it doesn't seem to be working correctly. No short description is displayed in the feed reader, all I see is the title of the article. Also, all of the articles say they were published at the same time. This is the first time I have tried to setup an RSS feed, so I'm sure I've made several stupid mistakes.
$result = mysql_query("SELECT * FROM blog ORDER BY id DESC LIMIT 10");
$date = date(DATE_RFC822);
header('Content-type: text/xml');
echo ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
echo ("<rss version=\"2.0\">\n");
echo ("<channel>\n");
echo ("<lastBuildDate>$date</lastBuildDate>\n");
echo ("<pubDate>$date</pubDate>\n");
echo ("<title>my website name</title>\n");
echo ("<description><![CDATA[the description]]></description>\n");
echo ("<link>http://my-domain.com</link>\n");
echo ("<language>en</language>\n");
$ch=100;
while ($a = mysql_fetch_array($result)) {
$headline = htmlentities(stripslashes($a['subject']));
$posturl = $a[perm_link];
$content = $a['post'];
$date = date(DATE_RFC822, $a['posted']);
echo ("<item>\n");
echo ("<title>$headline</title>\n");
echo ("<link>$posturl</link>\n");
echo ("<description><![CDATA[$content]]></description>\n");
echo ("<guid isPermaLink=\"true\">$posturl</guid>\n");
echo ("<pubDate>$date2</pubDate>\n");
echo ("</item>\n");
}
echo ("</channel>\n");
echo ("</rss>\n");
© Stack Overflow or respective owner