2009-06-08 78 views
0

嗨,我想知道是否有人可以帮助这个代码。我试图从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在这篇文章。对不起,我不能提供任何进一步的。

+0

是的,错误会很大。 :) – Christian 2009-06-08 10:16:53

回答

1

在第20行你打开一个if块,在第34行你打开一个for循环,但你关闭的时候,唯一的地方是在第49行你忘了关块之一。

+0

嗨,我已经注意到这一点,并增加了一个闭环在50行,这并没有消除错误,我尝试了额外的 53行,但没有工作。感谢你的协助。 – Ddywalgi 2009-06-08 10:29:18