创建一个rss feed并在Mysql上遇到一些麻烦

时间:2014-01-24 00:33:05

标签: php mysql rss

我似乎无法从mysql数据库中获取任何图像或标题,即使我已连接到实际的RSS源,我也不确定我做错了什么。

<?php
define ("DB_HOST", "xxx"); // set database host
define ("DB_USER", "xxx"); // set database user
define ("DB_PASS","fgbsh"); // set database password
define ("DB_NAME","adfgadg"); // set database name

$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");

$query = "SELECT story, description, pic, url FROM ".posts." WHERE status=1 ORDER BY   time_added desc";
$getBlogDisplay = mysql_query($query);

header("Content-type: text/xml"); 

echo "<?xml version='1.0' encoding='UTF-8'?> 
<rss version='2.0'>
<channel>
<title></title>
<link></link>
<description></description>
<language>en-us</language>"; 


while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){

 $title         = $dataBlogDisplay['story']; 
 $link          = $dataBlogDisplay['url'];
$description    = $dataBlogDisplay['pic'];

echo "<item> 
<title>$title</title>
<link>$url</link>
<description>$description</description>
</item>"; 
} 
echo "</channel></rss>";
?>

我很确定我的表名也正确。这是我一直在使用的教程

http://www.discussdesk.com/create-rss-feed-with-php-mysql.htm

0 个答案:

没有答案