views:

282

answers:

0

I am using the following script to generate a RSS feed for my site:

<?php

class RSS
{
    public function RSS()
    {
            $root = $_SERVER['DOCUMENT_ROOT'];
        require_once ("../connect.php");
    }

    public function GetFeed()
    {
        return $this->getDetails() . $this->getItems();
    }

    private function dbConnect()
    {
        DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
    }

    private function getDetails()
    {
        $detailsTable = "rss_feed_details";
        $this->dbConnect($detailsTable);
        $query = "SELECT * FROM ". $detailsTable ." WHERE feed_category = ''";
        $result = mysql_db_query (DB_NAME, $query, LINK);

        while($row = mysql_fetch_array($result))
        {
            $details = '<?xml version="1.0" encoding="ISO-8859-1" ?>
                    <rss version="2.0">
                        <channel>
                            <title>'. $row['title'] .'</title>
                            <link>'. $row['link'] .'</link>
                            <description>'. $row['description'] .'</description>
                            <language>'. $row['language'] .'</language>
                            <image>
                                <title>'. $row['image_title'] .'</title>
                                <url>'. $row['image_url'] .'</url>
                                <link>'. $row['image_link'] .'</link>
                                <width>'. $row['image_width'] .'</width>
                                <height>'. $row['image_height'] .'</height>
                            </image>';
        }
        return $details;
    }

    private function getItems()
    {
        $itemsTable = "rss_posts";
        $this->dbConnect($itemsTable);
        $query = "SELECT * FROM ". $itemsTable ." ORDER BY id DESC";
        $result = mysql_db_query (DB_NAME, $query, LINK);
        $items = '';
        while($row = mysql_fetch_array($result))
        {
            $items .= '<item>
                         <title>'. $row["title"] .'</title>
                         <link>'. $row["link"] .'</link>
                         <description><![CDATA['.$row["readable_date"]."<br /><br />".$row["description"]."<br /><br />".']]></description>
                     </item>';
        }
        $items .= '</channel>
                 </rss>';
        return $items;
    }

}

?>

The baffling thing is, the script works perfectly fine on my localhost but gives the following error on my remote server:

XML Parsing Error: junk after document element
Location: http://mysite.com/rss/main/
Line Number 2, Column 1:<b>Parse error</b>:  syntax error, unexpected T_STRING in <b>/home/studentw/public_html/rss/global-reach/rssClass.php</b> on line <b>1</b><br />
^

Can someone please tell me what's wrong?