I have created a feed from a blog script I am working on and have managed to get it working. But it just wont validate. Its the <pubdate/> thats giving me gip.
The feed content is fetched from mysql but the date stored in mysql is not a RFC-822 date time. So I need to convert it to RFC-822 some how.
I did read something here http://www.tech-recipes.com/mysql_tips1461.html about it which says I need to do the following mysql query
But I am unsure how to include this into my existing query without messing up my while loop.
What I have so far
Any ideas ?
Crowds
The feed content is fetched from mysql but the date stored in mysql is not a RFC-822 date time. So I need to convert it to RFC-822 some how.
I did read something here http://www.tech-recipes.com/mysql_tips1461.html about it which says I need to do the following mysql query
PHP Code:
SELECT DATE_FORMAT(pubdate,'%a, %d %b %Y %T') AS rfcpubdate FROM tablename WHERE 1
echo "<pubDate>$rfcpubdate ".date('T')."</pubDate>";
What I have so far
PHP Code:
<? header('Content-type: text/xml');
include_once '../Connections/CDblog.php'; ?>
<rss version="2.0">
<channel>
<title><? echo $btitle ?>News Feed</title>
<description>Latest News From <? echo $btitle ?></description>
<link><? echo $site ?></link>
<copyright><? echo $copy ?></copyright>
<?
mysql_connect($hostname_CDblog,$username_CDblog,$password_CDblog);
mysql_select_db($database_CDblog) or die( "Unable to select database");
$q="SELECT * FROM CDblg_article_art ORDER BY id_art DESC LIMIT 2";
$doGet=mysql_query($q);
while($result = mysql_fetch_array($doGet)){
?>
<item>
<title> <?=htmlentities(strip_tags($result['title_art'])); ?></title>
<description> <?=htmlentities(strip_tags($result['text_art'],'ENT_QUOTES'));?></description>
<link><? echo $site ?>article.php?id_art=<?=$result['id_art'];?></link>
<guid><? echo $site ?>article.php?id_art=<?=$result['id_art'];?></guid>
<pubDate> <?=strftime( "%a, %d %b %Y %T %Z" , $result['date_art']); ?></pubDate>
</item>
<? } ?>
</channel>
</rss>
Crowds
Comment