Je suis en train d'utiliser le script suivant pour générer un flux RSS pour mon site :
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 = '
'. $row['title'] .'
'. $row['link'] .'
'. $row['description'] .'
'. $row['language'] .'
'. $row['image_title'] .'
'. $row['image_url'] .'
'. $row['image_link'] .'
'. $row['image_width'] .'
'. $row['image_height'] .'
';
}
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 .= '
'. $row["title"] .'
'. $row["link"] .'
".$row["description"]."".']]>
';
}
$items .= '
';
return $items;
}
}
?>
La chose déconcertante, c'est que le script fonctionne parfaitement sur mon localhost mais donne l'erreur suivante sur mon serveur distant :
XML Parsing Error: junk after document element
Location: http://mysite.com/rss/main/
Line Number 2, Column 1:Parse error: syntax error, unexpected T_STRING in /home/studentw/public_html/rss/global-reach/rssClass.php on line 1
^