Hello, I have lurked these forms for many weeks now, and this is my first post here.
I am currently building a PHP website and I am trying to create an RSS feed that will automatically update the content of a blog database into the feed. So far, nothing I have done has worked. The closest I've been able to get is seeing the RSS feed page with the channel and description, but the content does not appear.
The file is called rss.php, and this is the code I am using.
<?php
header("Content-Type: application/rss+xml; charset=utf-8");
?>
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>My feed</title>
<link>http://www.somesite.com</link>
<description>Random ravings </description>
<?php
include ('database.php');
$sql = "SELECT * FROM blog_posts ORDER BY timestamp DESC LIMIT 5";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$date = date("M d", $row ['timestamp']);
$title = $row['title'];
$id = $row['id'];
$entry = $row['entry'];
echo "<title>" . $title . "</title>";
echo "<link>blog.php?id=" . $id . "</link>";
echo "<description>" . $entry . "</description>";
}
?>
</channel>
</rss>
But here is a screenshot of how the code looks when I open the browser. [
i28.tinypic.com ]
database.php would be my mySQL login info. I am running this code through my WAMP server. I am absolutely sure that the content is being pulled from the database, because if I remove the XML markups, the content is there.
I am assuming that I need to edit my server settings to allow XML to read PHP scripts, but I don't know how to do that. Any help would be appreciated. Thanks!