Ok, I've been playing around with my RSS feed file for my blog because I want to be able to use <enclosure> tags without having to use a service like feedburner which can convert your normal RSS files with MP3's, Bit Torrents, etc. links in them to the enclosures. That being said, I have it coded right now to do this, but the <enclosure> always shows up no matter if there is a media file or not, and that is not what I want. So how it works is that it looks in the database in a field called [torrent] and uses that determine the name, and size of the file. Because the <enclosure> tags are hard coded it will always show up. So I need to build some kind of IF/THEN statement around it to check if $torrentfile == "" then DON'T ADD IT. and finish off the rest of the RSS file. Otherwise it should add it and finish the rest. See my code below, and where the <enclosure url= is where it needs to be, between the <item> tags. Also heres my RSS Feed to see how it looks now. Notice the first <enclosure> doesn't have a file name at the end, like the second one does. I appreciate any help. Thanks. <? header("Content-type: text/xml\n\n"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <rss version=\"2.0\"> <channel> <title>$user[title]</title> <description>$user[description]</description> <link>$basepath1</link> <language>en-us</language> <generator>Blog</generator> "; $entries = mysql_query("SELECT * FROM bhost_entries WHERE u_id='$user[u_id]' AND privacy='3' AND draft='0' ORDER BY e_id DESC LIMIT $user[rss_entries]"); while($entry = mysql_fetch_assoc($entries)) { $basepath2 = url("entry_rss", "$user[username]", "$entry[e_id]"); $content = str_replace("'", "'", $entry['contents']); $title = str_replace("'", "'", $entry['title']); [B]$torrentfile = $entry['torrent'];[/B] $torrentsize = filesize('manager/torrents/'.$torrentfile); if($user[rss_html] == "0") { $content = strip_tags($content); $content = strip_tags($title); } $content = htmlspecialchars($content); $title = htmlspecialchars($title); echo " <item> <title>$title</title> <description>$content</description> <link>$basepath2</link> <enclosure url='$baseurl$torrentfile' length='$torrentsize' type='$torrenttype' /> </item> "; } echo " </channel> </rss>"; ?> PHP:
You are aware RSS is a fixed defined record and a custom record will not be parsed? You may need to use an XML feed for custom output that folks can read by your definition of the record.
Parsing the xml of the so called RSS and having the record correct for the RSS RFC are two different things.
you just need to do some check such as, isset($torrent) or isnull($torrent) and if (isset($torrent)){ echo " <enclosure .. . . . > "; } something along those lines heh shouldnt be difficult