Welcome to WebmasterWorld Guest from 54.159.179.132

Forum Moderators: bill & werty

Message Too Old, No Replies

Dynamic updation of rss with php-mysql

need help for Dynamic updation of rss with php and mysql

   
9:47 am on Mar 19, 2005 (gmt 0)

10+ Year Member



I m trying create rss feed which is database driven.
i have taken help of online documents. It is generating errors when seen in browser or RSS Aggregator.

databas name:testing
table: rss

The code which I m trying is:

<? header('Content-type: text/xml');?>
<?php
$con= mysql_connect('localhost','root','') or die('Unable to connect');
$db=mysql_select_db('testing') or die('unable to connect database');

?>
<rss version="2.0">
<channel>
<title>Name of your site</title>
<description>A description of your site</description>
<link>http://your_home_page_url/</link>
<copyright>Your copyright information</copyright>

<?
$getItems="SELECT id,title,body,UNIX_TIMESTAMP(datepub) AS pubDate from rss ORDER BY pubDate DESC";
$doGet=mysql_query($getItems);

while($item=mysql_fetch_array('$doGet'))
{
$id=$doGet['id'];
$title=strip_tags($doGet['title']);
$body=strip_tags($doGet['body']);
$body=substr($doGet['body'],0,150);
$pubDate=strftime("%a, %d %b %Y %T %Z",$doGet['pubDate']);

// output to browser

?>

<item>
<title><?php print htmlentities($title,'ENT_QUOTES');?></title>
<description><?php print htmlentities($body,'ENT_QUOTES');?></description>
<link>http://your_url/path/and_page.php?article=<?php print $id;?></link>
<pubDate><?php print $pubDate;?></pubDate>
</item>

<?
}
?>

</channel>
</rss>

The error generated is:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

--------------------------------------------------------------------------------

End tag 'channel' does not match the start tag 'br'. Error processing resource 'http://localhost/rss/index.php'. Line 12, ...

</channel>
--^

Kindly do help me out...

12:05 am on Mar 20, 2005 (gmt 0)

10+ Year Member



Not sure if any good php jockeys visit this forum a lot. If you don't get an answer in here soon I would suggest trying the same post over in the php [webmasterworld.com] forum.

Sorry I can't be more helpful.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month