1

我第一次尝试为网站的新闻页面构建动态 rss 提要文件。

所以我有以下代码

<?php
    header("Content-Type: application/rss+xml; charset=utf-8");

    echo'
        <?xml version="1.0" encoding="utf-8"?>
        <rss version="2.0">
        <channel>
            <title>My Site RSS feed</title>
            <guid>http://example.com/media/news.php</guid>
                    <link>http://www.exemple.com/mediacenter/news.php</link>
                     <description>This is an example RSS feed</description>
                    <language>en-US</language>              
    ';

    include('../misc/session.php'); // to get the language selected by user
    include('../includes/connection.php'); //connection to DB

    $idLang = $_SESSION['idLang'];


    $query = mysql_query("SELECT FROM tbl_news WHERE lang_id = '$idLang'");

    while($rs = mysql_fetch_array($query)){
        echo"
            <item>
                <title>".$rs['l_tltle']."</title>
                <link>a href='http://www.exemple.com/media/news.php'</link>
                <description><!CDATA['".$rs['l_text']."']></description>
            </item>
        ";
    }
    echo'
    </channel>
    </rss>
    ';
?>

在我的 index.php 文件中,在我得到这一行之前:

<link rel="alternate" type="application/rss+xml" title="MySite RSS Feed" href="http://mysite.com/rssfeed/rss.php" />

当我点击 Firefox 的图标时,它应该会打开一个带有 google reader 页面的页面,就像在其他网站中发生的那样,但在我的情况下,它会打开一个弹出窗口来保存文件。在 chrome 中,我有一个这个扩展,它检测到有一个提要。但它没有列出任何消息。

谁能帮我??什么不见​​了??

谢谢

4

1 回答 1

0

我有两个问题。

首先是在查询中。SELECT 后缺少 *。第二个错误在第二行。<?xml version="1.0"...必须与单引号在同一行。像这样echo' <?xml version="1.0" ...,否则它会给出验证错误,并且浏览器无法重新输入提要。

欢迎提出更多建议

于 2012-10-30T10:32:46.453 回答