tags:

views:

25

answers:

2

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]&lt;/link&gt;" . 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]&lt;/link&gt;" . 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&lt;/link&gt;
<image>
<src>http://www.funbyjohn.com/v2/media/thumb-1277466055.png&lt;/src&gt;
<title>Here's a new screenshot from Go Sheep!</title>
<link>http://www.funbyjohn.com/v2/?blog=heres-a-new-screenshot-from-go-sheep&lt;/link&gt;
</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

A: 

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 ]]>

kanenas.net
He's not using CDATA anywhere in the feed.
George Marian
This doesn't exactly answer my question but thanks for the tip nonetheless! I'm going to use CDATA as well. ;)
Johannes Jensen
+1  A: 

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

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

George Marian
...Oh. *facepalm* I knew it was something stupid.
Johannes Jensen