Taking tutorial submissions! Please email them to dave[AT]icemelon[DOT]com for review. Thanks!

Latest Tutorials
IceMelon IM: Add IM Functionality to phpBB [Misc] Want to add site-wide member IM to your phpBB community? Sure you do. Simple step-by-step instructions inside.

IceMelon IM: Add IM Functionality to vBulletin [Misc] Want to add site-wide member IM to your vBulletin community? Simple step-by-step instructions inside.

Crawl Your Site for PageRanks [PHP] So you know your site has a PageRank of 8. What about the PRs of all the inner pages? This tutorial will teach how you to automate the process of grabbing all these PRs.

Create CAPTCHA images [PHP] Worried about bots? Then create CAPTCHA images to prevent bots from taking advantage of your site.

Convert SHN and FLAC files to MP3 [Misc] Low on disk space and have an insensitive ear? Here are some steps to converting SHN and FLAC files to MP3 format.

[View All]

Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m.

Awesome Tutorials

Generate RSS Feeds
By dave

Here's the hypothetical situation. You're an enthusiastic weblogger. For your visitors' convenience, you want to offer them an RSS feed of your latest entries. Plus, you have a bad case of varicose veins.

Where do you start?

First, you will need to send the correct header information. Let your visitor's computer know XML code is oncoming.
Header('Content-type: text/xml');

Now, you're already ready to start sending your RSS code. If you know nothing about RSS, how it's formatted, etc., check this out: [http://blogs.law.harvard.edu/tech/rss]. No need to feel ashamed, because, in fact, I know nothing about this subject matter either (don't lose faith in the credibility of this tutorial, though). Here is an example of what tags and data you should start sending first:
echo "<?xml version=\"1.0\"?>n";
echo "<rss version=\"2.0\">n";
echo "   <channel>n";
echo "       <title>dave's weblog</title>\n";
echo "       <link>http://dave.nutang.com/</link>\n";
echo "       <description>A blog written by mr. dave</description>\n";
echo "       <language>en-us</language>\n";
echo "       <generator>IceMelon RSS Feeder</generator>\n";
echo "       <managingEditor>mr. dave</managingEditor>\n";
echo "       <webMaster>dave@nospam.com</webMaster>\n";

Next, come the <item> tags; AKA: your weblog entries. Each weblog entry you wish to post needs its own <item> stuff. Here's an example:
echo "       <item>\n";
echo "        <title>$weblogSubject</title>n";
echo "               <link>http://www.nutang.com/bliss/weblog/dave/& amp;comment=$weblogID</link>\n";
echo "               <pubDate>$weblogEntryDate</pubDate>\n";
echo "               <description> <![CDATA[ $blogEntryItself ]]> </description>\n";
echo "       </item>\n";

Finally, close off your XML/RSS tags:
echo "     </channel>\n";
echo "</rss> ";

Bypassing Pitfalls
RSS readers are very nitpicky. If you've already implemented the above, test it out with this RSS validator [http://rss.scripting.com]. If no errors are being reported, then you're either incredibly lucky, incredibly good, or.. your PHP code probably didn't even generate any RSS code.

If you do have errors, save yourself a lot of a debugging time by learning from my mistakes:
Mistake 1: XML, like HTML, support escaped characters in the '&..;' format. Therefore, if you need to use an ampersand (&), escape it: &amp; If you look at the sample code above, you'll see that's what I did for the weblog entry link.
Mistake 2: XML doesn't support HTML tags. To properly format your data then, use htmlentities and strip_tags . For example:
$blogEntryItself = htmlentities(strip_tags($blogEntryItself))

Aside:
As an additional safety measure, notice that I already wrapped $blogEntryItself inside '<![CDATA[..]]>' (seen in the sample PHP-generated RSS code). The CDATA section is supposed to be ignored by the XML parser. However, I've found that it can still throw errors. Those errors were fixed by the htmlentities tweak.

Alright, that's a wrap.

P.S. Check out my new site TheManWhoSoldtheWeb.com, where I publish guides and scripts on Internet Marketing and SEO. Here is a limited time freebie: the Rapid Google Indexer.


» Bookmark this Tutorial
» Bookmark IceMelon
Icemelon -- Generate RSS Feeds -- PHP, CSS, Javascript Tutorials, & More!
  © 2005-2010 Icemelon.com   Email: dave[AT]icemelon[D0T]c0m