ds111 Posted February 7, 2009 Share Posted February 7, 2009 Hi, I'm very new to RSS so was trying to get it to work into my content management system. Here's what i have: <? class RSS { public function GetFeed() { return $this->getDetails(); } private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } private function getDetails() { $detailsTable = "posts"; require_once ('registry/functions/function.connect_db.php'); connect_db (); $query = "SELECT * FROM ". $detailsTable; $result = mysql_query ($query); while($row = mysql_fetch_array($result)) { $link = 'http://localhost/Max.Blog v2.0/index.php?act=showpost&id='.$row['id']; $details = '<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0"> <channel> <title>'. $row['title'] .'</title> <link>'. $link .'</link> <description>'. $row['shortpost'] .''.$row['fullpost'].'</description> </channel> <item> <title>'. $row["title"] .'</title> <link>'. $link .'</link> <description><![CDATA['. $row["shortpost"] .']]></description> </item> '; } $details .= '</channel> </rss>'; return $details; } private function getItems() { /*$itemsTable = "webref_rss_items"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable; $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["description"] .']]></description> </item>'; } $items .= '</channel> </rss>'; */ // return $items; } } ?> thats the class and for rss.php: <? header("Content-Type: application/xml; charset=ISO-8859-1"); include("registry/classes/class.rss.php"); $rss = new RSS(); echo $rss->GetFeed(); ?> This results in: XML Parsing Error: not well-formed Location: http://localhost/Max.Blog%20v2.0/rss.php Line Number 5, Column 69: <link>http://localhost/Max.Blog v2.0/index.php?act=showpost&id=7</link> --------------------------------------------------------------------------------------------------------------^ Can anyone help? Thanks!! Link to comment https://forums.phpfreaks.com/topic/144153-php-rss-dynamic/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.