Tutorial :php + rss: why isn't the image showing up?



Question:

I'm making my own RSS feed in PHP for my website, which loads the blog my website has from a table called 'blog', it all works as it should except for one thing...no images are showing up at the articles. Here's the output piece of my code:

while($data = mysql_fetch_assoc($news))  {      echo "<item>" . chr(10);      echo "<title>[$data[type]] $data[name]</title>" . chr(10);      echo "<author>Johannes Jensen</author>" . chr(10);      echo "<link>http://www.funbyjohn.com/v2/?blog=$data[url]</link>" . chr(10);      echo "<image>" . chr(10);        if($data["type"] == "text")      {          $imageurl = "http://www.funbyjohn.com/v2/gfx/mini_me.png";      } else      {          $imageurl = "http://www.funbyjohn.com/v2/media/thumb-$data[date].png";      }        echo "<src>$imageurl</src>" . chr(10);      echo "<title>$data[name]</title>" . chr(10);      echo "<link>http://www.funbyjohn.com/v2/?blog=$data[url]</link>" . chr(10);      echo "</image>" . chr(10);        if($data["type"] == "text")      {          $content = $data["content"];      } else      {          $content = $data["label_info"];      }        echo "<description>" . strip_tags(preg_replace("/\n+/", " ", $content)) . "</description>" . chr(10);      echo "<pubDate>" . date("D, j M Y H:i:s", $data["date"]) . " GMT</pubDate>" . chr(10);      echo "</item>" . chr(10);  }  

And here's an example of the output of an article

<item>  <title>[image] Here's a new screenshot from Go Sheep!</title>  <author>Johannes Jensen</author>  <link>http://www.funbyjohn.com/v2/?blog=heres-a-new-screenshot-from-go-sheep</link>  <image>  <src>http://www.funbyjohn.com/v2/media/thumb-1277466055.png</src>  <title>Here's a new screenshot from Go Sheep!</title>  <link>http://www.funbyjohn.com/v2/?blog=heres-a-new-screenshot-from-go-sheep</link>  </image>  <description>*article goes here*</description>  <pubDate>Fri, 25 Jun 2010 06:40:55 GMT</pubDate>  </item>  

Am I doing something wrong? Please help.

And here's my RSS feed for anyone that's interested:
http://www.funbyjohn.com/v2/rss.php


Solution:1

I think you need to use <url> intead of <src>.

http://cyber.law.harvard.edu/rss/rss.html#ltimagegtSubelementOfLtchannelgt


Solution:2

CDATA - (Unparsed) Character Data

The term CDATA is used about text data that should not be parsed by the XML parser.

Characters like "<" and "&" are illegal in XML elements.

"<" will generate an error because the parser interprets it as the start of a new element.

"&" will generate an error because the parser interprets it as the start of an character entity.

Some text, like javascript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA.

Everything inside a CDATA section is ignored by the parser.

A CDATA section starts with <![CDATA[ and ends with ]]>


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »