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?)
<?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("<", "<", $productImage);
$productImage = str_replace(">", ">", $productImage);
//$productImage = str_replace("&", "&", $productImage);
$productDescriptions = '<p>'. stripslashes($row['product_rss_details']) .'</p>';
$productDescriptions = str_replace("&", 'and', $productDescriptions);
$productDescriptions = str_replace("<", "<", $productDescriptions);
$productDescriptions = str_replace(">", ">", $productDescriptions);
$productDescriptions = str_replace(""", '"', $productDescriptions);
$productDescriptions = str_replace(" ", ' ', $productDescriptions);
//$productDescriptions = str_replace("&", "&", $productDescriptions);
$otherText = '<p><a href="http://www.mookle.com.au/index.php?city_id='. $this->cityId .'">Read more...</a></p>';
$otherText = str_replace("<", "<", $otherText);
$otherText = str_replace(">", ">", $otherText);
//$otherText = str_replace("&", "&", $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'];
}
}