Trying to create an RSS feed...but failing..need help!
Hi all,
I have a personal Webpage that I am trying to create an RSS feed for easier viewing. I'm so close. My page is php/mysql, all developed by hand. It's pretty simple and straightforward. The database side of it is very solid. Not saying I know everything about it, but I did build all of it!
I've known about RSS feeds for a long time, and I am just now starting to actually use them and I really want to implement one for my page. It seems easy and I found a great tutorial at this link:
The file I created is saved in my web folders root directory as feed.xml. (When I double click it in the web folder it has me download the file, which I do, and it gives a standard xml error saying "Cannot view XML input using style sheet. Invalid at the top level of the document." If I go to www.craiggreenwood.com/feed.xml I just get "Cannot display this feed".)
The connect file in the code below I have renamed for security, but I know the connection file is working fine because it is used throughout the site with success.
I have done my best to rename the tables and columns from the tutorial to match my database. Here is a summary of that info:
table name: TblJournal
columns in the table: id, entry, Title, Category, date (I am only using id, entry and Title for this RSS feed)
Below is the code I have created based on the tutorial I linked above. What have I missed? Any help would be welcome!
Code:
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
// Set RSS version.
echo "
<rss version=\"2.0\">";
// Start the XML
echo "
<channel>
<title>www.CraigGreenwood.com Journal</title>
<description>Keep up to date on Craig Greenwood's life. Subscribe here!</description>
<link>http://www.craiggreenwood.com/journal.php/</link>";
// Create a connection to your database.
require("connection_information.php");
// Query database and select the last 10 entries.
$data = mysql_query("Select * from tblJournal order by id desc limit 10");
while ($row = mysql_fetch_array($data))
{
// Convert database images data into actual image link.
// $row[entry] = str_replace("images/", "http://www.craiggreenwood.com/journal/", $row{entry]);
// Continue with the 10 items to be included in the <item> section of the XML.
echo "
<item>
<link>http://www.craiggreenwood.com/journal.php</link>
<guid isPermaLink=\"true\">http://www.craiggreenwood.com\journal.php</guid>
<title>".$row[Title]."</title>
<description><![CDATA[".substr($row[entry],0,150)."]]></description>
</item>";
}
echo "
</channel>
</rss>";
?>
If more information is needed please ask. I would love to get this working so I can be cool and brag to all the babes.
Bookmarks