当您拉取 RSS 提要时,它会显示 1 个帖子,但在该帖子中,所有其他帖子都会显示。我检查了我所有的关闭,并一遍又一遍地修改了代码,但看不出问题出在哪里。在某些 RSS 阅读器上,它只是说错误无法读取提要。但在其他人我有这个问题。
任何方向都会有所帮助。下面的代码:
<?PHP
$host = "****";
$un = "****";
$pw = "****";
$db = "****";
$link = mysql_connect($host, $un, $pw) or die(mysql_error());
if(!$link){ die("Could not connect to MARTHA GRAEFF - AROUND IN STYLE database: " . mysql_error()); }
$selectDB = mysql_select_db($db, $link) or die(mysql_error());
if (!$selectDB){ die ("Can't use MARTHA GRAEFF - AROUND IN STYLE database: " . mysql_error()); }
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<rss version="2.0">';
echo '<channel>';
echo '<title>TITLE OF THE FEED</title>';
echo '<description>BLOG DESCRIPTION</description>';
echo '<link>http://www.example.com</link>';
$get_articles = "SELECT `id`, `title`, `image`, `text`, DATE_FORMAT(`date`,'%a, %e %b %Y') as `date` FROM `posts` WHERE `date` <= CURDATE() ORDER BY `added` DESC LIMIT 20";
$articles = mysql_query($get_articles);
while($a = mysql_fetch_array($articles)){
echo "<item>";
echo "<title>" . $a['title'] . "</title>";
echo "<description><![CDATA[";
echo "<img src='http://www.example.com/images/db/thumb.php?src=" . $a['image'] . "&w=650' width='650' alt='" . $a['title'] . "' /><br />";
$pid = $a['id'];
$q = "SELECT * FROM `photos` WHERE `post_id`='" . $pid . "' ORDER BY `added` ASC";
$r = mysql_query($q);
while($i = mysql_fetch_array($r)){
echo "<img src='http://www.example.com/images/db/thumb.php?src=" . $i['image'] . "&w=650' width='650' alt='" . $a['title'] . "' /><br />";
}
echo $a['text'];
echo "]]></description>";
echo "<link>http://www.example.com/post.php?id=" . $a['id'] . "</link>";
echo "<pubDate>" . $a['date'] . " EST</pubDate>";
echo "</item>";
}
echo "</channel>";
echo "</rss>";
?>