SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML error: "Extra content at end of document"

    I am getting an error saying "Extra content at end of document" everytime I try to run the script below: (anyone got an idea of why this is happening?)

    Code PHP:
    <?php
     
      class RSS
     
      {
     
    	var $cityId;
     
    	var $cityName;
     
    	public function RSS()
     
    	{
     
    		require_once ('mysql_connect.php');
     
    	}
     
     
     
    	public function GetFeed($getCityId)
     
    	{
     
    		if($getCityId!='' && $getCityId > 0){
     
    			$this->cityId = $getCityId;
     
    		}else{
     
    			$this->getDefaultCity();
     
    			$this->cityId = $this->cityId;
     
     		}
     
    		$this->getCity();
     
    		return $this->getDetails() . $this->getItems();
     
    	}
     
     
     
    	private function dbConnect()
     
    	{
     
    		DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
     
    	}
     
     
     
    	private function getDetails()
     
    	{
     
    		$details = '<?xml version="1.0" encoding="UTF-8"?>
     
    					<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
     
    					<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
     
    					<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
     
    						<channel>
     
    							<title>The Mookle Daily mail - '. $this->cityName .'</title>
     
    							<description>Get enough people to win a massive discount on something fun to do in '. $this->cityName .'</description>
     
    							<link>http://www.mookle.com.au/index.php?city_id='. $this->cityId .'</link>
     
    							<language>en</language>
     
    							<pubDate>'. date("D, d M Y H:i:s O") .'</pubDate>
     
    							<ttl>60</ttl>
     
    							<atom:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://www.unipon.com.au/rssfeed/uniponfeed.php?cityId='. $this->cityId .'" />
     
    					';
     
    		return $details;
     
    	}
     
     
     
    	private function getItems()
     
    	{
     
    		$itemsTable = "products";
     
    		$this->dbConnect($itemsTable);
     
    		$query = "SELECT * FROM ". $itemsTable ." WHERE city_id=". $this->cityId ." AND product_status=1 AND (".time()." BETWEEN product_starting_date AND product_closing_date) AND deal_status='open'";
     
    		$result = mysql_db_query (DB_NAME, $query, LINK);
     
    		$items = '';
     
    		if(mysql_num_rows($result)){
     
    			$row = mysql_fetch_array($result);
     
    			$productImage = '<img align="right" alt="'. stripslashes(str_replace("&", "and", $row['product_name'])) .'" src="http://www.unipon.com.au/products/t/'. $row['product_id'] .'.jpg" width="120" />';
     
    			$productImage = str_replace("<", "&lt;", $productImage);
     
    			$productImage = str_replace(">", "&gt;", $productImage);
     
    			//$productImage = str_replace("&", "&amp;", $productImage);
     
     
     
    			$productDescriptions = '<p>'. stripslashes($row['product_rss_details']) .'</p>';
     
    			$productDescriptions = str_replace("&", 'and', $productDescriptions);
     
    			$productDescriptions = str_replace("<", "&lt;", $productDescriptions);
     
    			$productDescriptions = str_replace(">", "&gt;", $productDescriptions);
     
    			$productDescriptions = str_replace("&quot;", '"', $productDescriptions);
     
    			$productDescriptions = str_replace("&nbsp;", ' ', $productDescriptions);
     
     
     
    			//$productDescriptions = str_replace("&", "&amp;", $productDescriptions);
     
     
     
    			$otherText = '<p><a href="http://www.mookle.com.au/index.php?city_id='. $this->cityId .'">Read more...</a></p>';
     
    			$otherText = str_replace("<", "&lt;", $otherText);
     
    			$otherText = str_replace(">", "&gt;", $otherText);
     
    			//$otherText = str_replace("&", "&amp;", $otherText);
     
     
     
    			$items .= '<item>
     
    				<title>'. stripslashes(str_replace("&", "and", $row['product_name'])) .'</title>
     
    				<description>'. $productImage .' '. $productDescriptions .' '. $otherText .'</description>
     
    				<link>http://www.mookle.com.au/index.php?city_id='. $this->cityId .'</link>
     
    				<guid>http://www.mookle.com.au/index.php?city_id='. $this->cityId .'</guid>
     
    				<pubDate>'. date("D, d M Y H:i:s O", $row["product_starting_date"]) .'</pubDate>
     
    			</item>';
     
    		}else{
     
    			$items .= '<item>
     
    				<title>'. $this->cityName .'\'S DEAL OF THE DAY</title>
     
    				<description>SOMETHING GREAT TO DO, EAT, SEE, OR BUY IN FRESNO, DELIVERED TO YOUR INBOX EVERY MORNING</description>
     
    				<link>http://www.mookle.com.au/manage_subscription.php?city_id='. $this->cityId .'</link>
     
    				<guid>http://www.mookle.com.au/manage_subscription.php?city_id='. $this->cityId .'</guid>
     
    				<pubDate>'. date("D, d M Y H:i:s O") .'</pubDate>
     
    			</item>';
     
    		}
     
    		$items .= '</channel>
     
    				</rss>';
     
    		return $items;
     
    	}
     
     
     
    	function getCity(){
     
    		$cityTable = "cities";
     
    		$this->dbConnect($cityTable);
     
    		$query = "SELECT city_name FROM ". $cityTable." WHERE city_id=".$this->cityId."";
     
    		$result = mysql_db_query (DB_NAME, $query, LINK);
     
    		$row = mysql_fetch_array($result);
     
    		$this->cityName = $row['city_name'];
     
    	}
     
     
     
    	function getDefaultCity(){
     
    		$cityTable = "cities";
     
    		$this->dbConnect($cityTable);
     
    		$query = "SELECT city_id, city_name FROM ".$cityTable." WHERE city_home=1";
     
    		$result = mysql_db_query (DB_NAME, $query, LINK);
     
    		$row = mysql_fetch_array($result);
     
    		$this->cityId = $row['city_id'];
     
    	}
     
     
     
    }
    Last edited by Mittineague; Nov 25, 2010 at 22:42. Reason: reformatting bbcode tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •