Hi Guys,

I am trying to create an RSS in PHP. I have the following code which should work but I get an error saying FEED ERROR when I run the code. The code does run and display an XML file if I remove <rss version="2.0"> , I really don't know what the problem could be. Please see if you can help me find a solution.

Many thanks in advance

I have the following code

<?   
2   
3   class RSS   
4   {   
5     public function RSS()   
6     {   
7         require_once ('pathto.../mysql_connect.php');   
8     }   
9   
10     public function GetFeed()   
11     {   
12         return $this->getDetails() . $this->getItems();   
13     }   
14   
15     private function dbConnect()   
16     {   
17         DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));   
18     }   
19   
20     private function getDetails()   
21     {   
22         $detailsTable = "webref_rss_details";   
23         $this->dbConnect($detailsTable);   
24         $query = "SELECT * FROM ". $detailsTable;   
25         $result = mysql_db_query (DB_NAME, $query, LINK);   
26   
27         while($row = mysql_fetch_array($result))   
28         {   
29             $details = '<?xml version="1.0" encoding="ISO-8859-1" ?>   
30                 <rss version="2.0">   
31                     <channel>   
32                         <title>'. $row['title'] .'</title>   
33                         <link>'. $row['link'] .'</link>   
34                         <description>'. $row['description'] .'</description>   
35                         <language>'. $row['language'] .'</language>   
36                         <image>   
37                             <title>'. $row['image_title'] .'</title>   
38                             <url>'. $row['image_url'] .'</url>   
39                             <link>'. $row['image_link'] .'</link>   
40                             <width>'. $row['image_width'] .'</width>   
41                             <height>'. $row['image_height'] .'</height>   
42                         </image>';   
43         }   
44         return $details;   
45     }   
46   
47     private function getItems()   
48     {   
49         $itemsTable = "webref_rss_items";   
50         $this->dbConnect($itemsTable);   
51         $query = "SELECT * FROM ". $itemsTable;   
52         $result = mysql_db_query (DB_NAME, $query, LINK);   
53         $items = '';   
54         while($row = mysql_fetch_array($result))   
55         {   
56             $items .= '<item>   
57                 <title>'. $row["title"] .'</title>   
58                 <link>'. $row["link"] .'</link>   
59                 <description><![CDATA['. $row["description"] .']]></description>   
60             </item>';   
61         }   
62         $items .= '</channel>   
63                 </rss>';   
64         return $items;   
65     }   
66   
67 }   
68   
69 ?>

and the header file is

<?   
2   header("Content-Type: application/xml; charset=ISO-8859-1");   
3   include("classes/RSS.class.php");   
4   $rss = new RSS();   
5   echo $rss->GetFeed();   
6 ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.