嗨,我想知道是否有人可以幫助這個代碼。我試圖從URL表中顯示某個類別的記錄,例如url_category_id = 1,其中url和category在關聯表中相同。 我有這個rss的一些問題,因爲它有一個55行解析錯誤。我試圖解決這個問題,但無濟於事。PHP RSS不解析在第55行
<?php $db = new mysqli("Host", "USER", "PW", "DB");?>
<?php header('Content-type: text/xml'); ?>
<?php echo "<?";?>xml version="1.0" encoding="iso-8859-1"<?php echo "?>";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>My TITLE</title>
<description>My DESCRIPTION</description>
<link>www.MyWeb</link>
<copyright>C) 2009 All Rights Reserved</copyright>
<atom:link href="http://source of feed" rel="self" type="application/rss+xml" />
<?php
$query = 'SELECT * FROM url_categories WHERE url_category_id= $type';
$result = mysql_query ($query);
if (isset($_GET['type'])) {
$type = (int) $_GET['type'];
} else {
$type = 3;
}
if ($type > 0) {
// Get the current type name.
$query = "SELECT category FROM url_categories WHERE url_category_id=$type";
$result = mysql_query ($query);
list ($category) = mysql_fetch_array ($result, MYSQL_NUM);
$first = TRUE; // Initialize the variable.
// Query the database.
$query = "SELECT u.url_id, url, title, description, pub_date, STR_TO_DATE(pub_date, '%d-%b-%Y') AS sortdate, DATE_FORMAT(STR_TO_DATE(pub_date, '%d-%b-%Y'), '%d.%b.%Y') FROM urls AS u, url_associations AS ua WHERE u.url_id = ua.url_id AND ua.url_category_id=$type AND ua.approved = 'Y'ORDER BY sortdate DESC";
$result = mysql_query ($query);
$num_records = mysql_num_rows($result);
$number = $results->num_rows;
for ($i = 1; $i <= $number; $i++) {
$row = $results->fetch_assoc();
$title = $row['title'];
$description = $row['description'];
$url = $row['url'];
$date = $row['sortdate'];
?>
<item>
<title><?php echo $title; ?></title>
<description><?php echo $description; ?></description>
<link><?php echo "http://";?><?php echo $url; ?></link>
<guid><?php echo "http://";?><?php echo $url; ?></guid>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($date)); ?></pubDate>
</item>
<?php
}
?>
</channel>
</rss>
<?php
$db->close();
?>//This is the parse error line
我將是在試圖解決這個問題的任何援助表示感謝。
所有我收到的語法錯誤就行52,如果我改變它,我得到55行語法錯誤..沒有理由的錯誤,但我已經注意到了代碼段是不承認它作爲PHP在這篇文章。對不起,我不能提供任何進一步的。
是的,錯誤會很大。 :) – Christian 2009-06-08 10:16:53