Hi forum,
Trying to create an RSS feed for my blog (not using a blog host or blog software). Seems to me the best way for me to do it is to use PHP in the XML to draw the last X posts from my MySQL database. So first, I added a .htaccess file to the directory with the line AddType application/x-httpd-php .xml
...to make the php work inside the xml file.
My rss.xml looks like:
<?php header('Content-type: text/xml'); ?>
<rss version="2.0">
<?php
(connection goes here)
(recordset goes here)
?>
<channel>
<title>X</title>
<description>I like the Internet</description>
<link>http://www.x.com</link>
<?php
mysql_select_db($aCon, $acCon);
$top5q="SELECT blogIndex,title,content,DATE_FORMAT(date,'%a, %d %b %Y %T') AS rfcdate,tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10 FROM rhododendrites_blog ORDER BY date DESC LIMIT 10";
$recentp = mysql_query($top5q,$acCon) or die(mysql_error());
while($row=mysql_fetch_array($recentp))
{ ?>
<item>
<title><?php
echo htmlentities(strip_tags($row['title'])); ?>
</title>
<description>
<?php echo $row['content']; ?>
</description>
<link>http://www.x.com/blog/post.php?blogid=<?php echo $row['blogIndex']; ?></link>
<pubDate><?php echo $row['rfcdate']; ?></pubDate>
</item>
<?php } ?>
</channel>
</rss>
I changed my website, of course, to x.com and the names of a couple vars. I'm new at this stuff and don't know what I should be paranoid about :) Sorry.
So not only does it not show any records (other than the initial channel info) when I surf to the URL of the feed directly, but when I try to validate it, I get this:
Sorry
This feed does not validate.
line 89, column 42: pubDate must be an RFC-822 date-time:
<pubDate><?php echo $row; ?></pubDate>
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
Feeds should not be served with the "application/x-httpd-php" media type
line 84, column 3: title should not be blank
</title>
line 90, column 2: item should contain a guid element
</item>
line 93, column 0: Missing atom:link with rel="self"
</channel>
Help? :/ Spent hours on this so far and can't figure it out.