tags:

views:

99

answers:

2

Hi I wonder if anyone can help with this code. I am trying to show the records from a URL table for a category, eg url_category_id = to 1. where the url and category is the same in the associating table. I am having some issues with this rss as it has a parse error on line 55. I have tried to resolve the issue but without avail.

 <?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"&gt;
<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://";?&gt;&lt;?php echo $url; ?></link>
<guid><?php echo "http://";?&gt;&lt;?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

I would be grateful for any assistance in trying to resolve this issue.

Kind regards,

Sean

A: 

Please provide further information (error message, ...)

Lichtamberg
All I am receiving is parse error on line 52 and if I alter it I get parse error on line 55 .. no reason as to the error, but I have noticed the code section isn't recognising it as php in this post. Sorry I can't offer anything further.
Ddywalgi
Did you solved it?
Lichtamberg
+1  A: 

In line 20 you open an if block, in line 34 you open a for loop, but the only place you close something is in line 49. You forgot to close one of the blocks.

Daan
Hi I had noticed this and added a closed loop at Line 50 this didn't remove the error and I tried an extra <?php }?> at line 53 but none have worked. Thanks for your assistance.
Ddywalgi