PDA

View Full Version : Help with RSS Feed



fodo
07-17-2009, 05:37 PM
I want to extract data form mysql format it with php as an xml/rss feed and display the results in a web page.
My code seems to work and displays in ff until you bookmark the link.
It doesnt work in safari or ie.
I would like to amend the code to write to a file and then link to that, but first i would like to confirm my feed is ok.
Can any one suggest the problem in echo the $rssfeed?
link http://217.46.159.226/wordpress/
feed link is on the Publisher page .feed
[CODE]
<?php
ob_start();
/*
Template Name: feed
*/
?>
<?php
DEFINE ('DB_USER', '');
DEFINE ('DB_PASSWORD', '');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', '');

$rssfeed = '<?xml version="1.0"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>New Stories</title>';
$rssfeed .= '<link>http://localhost/wordpress</link>';
$rssfeed .= '<description>Feed for Publishers</description>';
$rssfeed .= '<language>en-us</language>';
$rssfeed .= '<copyright>Copyright (C) 2009 Hawkesley Publishing Solutions Ltd</copyright>';

$connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
or die('Could not connect to database');
mysql_select_db(DB_NAME)
or die ('Could not select database');

$query = "SELECT * FROM book";
$result = $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

while($row = mysql_fetch_array($result)) {
extract($row);

$rssfeed .= '<item>';
$rssfeed .= '<title>' . $WorkingTitle . '</title>';
$rssfeed .= '<description>' . $BriefDescription . '</description>';
$rssfeed .= '<link>' . $link . '</link>';
/*$rssfeed .= '<pubDate>' . EntryDate("D, d M Y H:i:s O", strtotime($date)) . '</pubDate>';*/
$rssfeed .= '</item>';
}

$rssfeed .= '</channel>';
$rssfeed .= '</rss>';

?>
<?php get_header();?>
<div id="leftnav">

<?php include (TEMPLATEPATH . '/sidebar1.php'); ?>

<div id="right_pan".
</div>
</div>

<div id="rightnav">
</div>

<div id="content">
<?php
ob_end_clean();
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
echo $rssfeed;
?>
</div>
<?php get_footer();?>
[CODE]