Hi i am trying to create an RSS feed for my mobile application. I seem to be getting an error that i cannot seem to solve. I was hoping someone here could enlighten me.
index.php
<?
header("Content-Type: application/xml; charset=ISO-8859-1");
include("RSS.class.php");
$rss = new RSS();
echo $rss->GetFeed();
?>
this is the RSS.class.php file
<?
class RSS
{
public function RSS()
{
// select which database file to link to
require_once ('http://www.niccloud.byethost12.com/RSS_Feed/my_sql_connect.php');
}
// this function will collate all of the details/items and show as valid RSS 2.0 structure
public function GetFeed()
{
return $this->getDetails() . $this->getItems();
}
// connect to the database
private function dbConnect()
{
DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
}
// makes connection to table and selects all of the values
// when complete, getDetails returns the details for the RSS structure
private function getDetails()
{
$detailsTable = "outlet";
$this->dbConnect($detailsTable);
$query = "SELECT * FROM ". $detailsTable;
$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>
<name>'. $row['name'] .'</name>
<unit>'. $row['unit'] .'</unit>
<contact>'. $row['contact'] .'</contact>
<operating_hrs>'. $row['operating_hrs'] .'</operating_hrs>
<category>'. $row['category'] .'</category>
<email>'. $row['email'] .'</email>';
// <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 = "mall";
$this->dbConnect($itemsTable);
$query = "SELECT * FROM ". $itemsTable;
$result = mysql_db_query (DB_NAME, $query, LINK);
$items = '';
while($row = mysql_fetch_array($result))
{
$items .= '<item>
<mall>'. $row["mall"] .'</mall>
<location>'. $row["location"] .'</location>
</item>';
}
$items .= '</channel>
</rss>';
return $items;
}
}
?>
I seem to be getting an
XML Parsing Error: no element found
Location: http://www.niccloud.byethost12.com/RSS_Feed/index.php
Line Number 1, Column 1:
error i cannot seem to solve. Thanks