<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>edrackham</title>
	<link>http://edrackham.com</link>
	<description>PHP, MySQL, and Other Web Snippets!</description>
	<pubDate>Wed, 25 Jun 2008 13:38:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Awesome Form Validation</title>
		<link>http://edrackham.com/uncategorized/awesome-form-validation/</link>
		<comments>http://edrackham.com/uncategorized/awesome-form-validation/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 13:33:00 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://edrackham.com/uncategorized/awesome-form-validation/</guid>
		<description><![CDATA[I don&#039;t know about you, but I always work hard on my form validation (and would never use just JUST JavaScript to validate input locally). It puts a smile on my face when a form is technically valid, yet won&#039;t submit:

]]></description>
			<content:encoded><![CDATA[<p>I don&#039;t know about you, but I always work hard on my form validation (and would never use just JUST JavaScript to validate input locally). It puts a smile on my face when a form is technically valid, yet won&#039;t submit:</p>
<p><img src="http://edrackham.com/images/posts/awesome-form-validation.jpg" alt="Awesome Form Validation" /></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/uncategorized/awesome-form-validation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple Web 2.0 Design and CSS Tutorial</title>
		<link>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/</link>
		<comments>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 16:37:28 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Photoshop]]></category>
<category>css</category><category>layout</category><category>photoshop</category><category>Tutorial</category><category>web2.0</category><category>xhtml</category>
		<guid isPermaLink="false">http://edrackham.com/css/simple-web-20-design-and-css-tutorial/</guid>
		<description><![CDATA[This tutorial aims at teaching you how to make a simple &#034;Web 2.0&#034; design.


Setup
To start, let&#039;s create a new document in Photoshop, 1024px (width) by 700px (height).


Guides
Now, lets set up predefined areas (for areas like the header, and content) using guides. We will be creating four guides for now.



First Guide: Horizontal, position: 160px
Second Guide: Horizontal, [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial aims at teaching you how to make a simple &#034;Web 2.0&#034; design.</p>
<p><a href='http://www.mediafire.com/?m1umgjhexzv' title="Download all the files used in this tutorial"><img src="http://edrackham.com/images/download_tut_files.png" alt="Download Tutorial Files" border="0" /></a></p>
<p><a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design"><img src="http://edrackham.com/images/view_it.png" alt="View Final Design" border="0" /></a></p>
<h3>Setup</h3>
<p>To start, let&#039;s create a new document in Photoshop, 1024px (width) by 700px (height).</p>
<p><a href="http://imgplace.com/image/view/035e6910e639bb75b011705577421ed9" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/2510/035e6910e639bb75b011705577421ed9.png.th.jpg" border="0" alt="Document Setup"></a></p>
<div style="clear: both;"></div>
<h3>Guides</h3>
<p>Now, lets set up predefined areas (for areas like the header, and content) using guides. We will be creating four guides for now.</p>
<p><a href="http://imgplace.com/image/view/7b82fc1da823cdc0474ac72b18234e98" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/3291/7b82fc1da823cdc0474ac72b18234e98.png.th.jpg" border="0" alt="Creating New Guides"></a></p>
<div style="clear: both;"></div>
<ul>
<li><strong>First Guide:</strong> Horizontal, position: 160px</li>
<li><strong>Second Guide:</strong> Horizontal, position: 620px</li>
<li><strong>Third Guide:</strong> Vertical, position: 62px</li>
<li><strong>Fourth Guide:</strong> Vertical, position: 962px</li>
</ul>
<p>You should now have something that resembles the following (ignore the fact that there&#039;s the BG coloured in there, that wasn&#039;t supposed to be there just yet):</p>
<p><a href="http://imgplace.com/image/view/8427781b4c9e2dbb44c11cd24a058a85" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/4841/8427781b4c9e2dbb44c11cd24a058a85.png.th.jpg" border="0" alt="Our Guides"></a></p>
<div style="clear: both;"></div>
<h3>Background</h3>
<p>&#034;Web 2.0&#034; seems to be all about gradients, so choose a foreground and background colour. I used foreground: #6d6657 and background: #302a1d. Use the gradient tool, then click at the top of the document, and drag down to the first horizontal guide (160px down). You should have something like the following:</p>
<p><a href="http://imgplace.com/image/view/ce7986f13ebd89efe64d6cad3adf9ad5" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/8870/ce7986f13ebd89efe64d6cad3adf9ad5.png.th.jpg" border="0" alt="Background"></a></p>
<div style="clear: both;"></div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h3>Content Area</h3>
<p>Choose the rounded rectangle tool, and set a corner radius of 10px. Now make sure that your window is expanded a little more than the actual document size so that you can begin to draw your content area just outside the top of the document. Start about 15px above the document, and at the first vertical guide (62px in). Drag out a rounded rectangle down to the bottom horizontal guide, and aligned with the right hand vertical guide (962px in). You should see the following:</p>
<p><a href="http://imgplace.com/image/view/124c5d9ec60354b9d440c5243440910b" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/5796/124c5d9ec60354b9d440c5243440910b.png.th.jpg" border="0" alt="Content Background"></a></p>
<div style="clear: both;"></div>
<p>Now, add the following layer style to the rounded rectangle:</p>
<p><a href="http://imgplace.com/image/view/b16464d0997d72b4d8342e82f512a7d3" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/9182/b16464d0997d72b4d8342e82f512a7d3.png.th.jpg" border="0" alt="Content Area Style"></a></p>
<div style="clear: both;"></div>
<h3>Header</h3>
<p>Now lets set up the header. Create a new layer and use the Rectangular Marquee Tool and draw from the top left of the document all the way to the right, and down to the first horizontal guide. Fill with a colour of your choice. If you&#039;re following this guide, I used #918977. Change the blend mode to &#039;Darker Color&#039; and add a drop shadow using the following settings:</p>
<p><a href="http://imgplace.com/image/view/8c4fb525fdd13ba1fc957d37866370d1" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/9816/8c4fb525fdd13ba1fc957d37866370d1.png.th.jpg" border="0" alt="Header Style"></a></p>
<div style="clear: both;"></div>
<p>Now grab a decent pattern, there are some nice ones at <a href="http://squidfingers.com/patterns/" title="Lots of nice patterns">SquidFingers</a>. Choose one, open it in photoshop and <a href="http://www.hongkiat.com/blog/creating-custom-pattern-in-photoshop/" title="How to define a pattern in Photoshop">define it as a pattern</a> (steps 1 &#038; 2 only). <strong>IMPORTANT:</strong> Remember the width of the image. Mine is 34px. Once you have your pattern defined, bring up the main layout document we&#039;re working on and Ctrl+Click on the image part of the header layer in the layers panel. This should have selected the header section. Create a new layer above and choose Edit > Fill. Select your newly defined pattern, and fill this header area.</p>
<p>Now, set the Blending Mode to Luminosity, and press Q to enter Quick Mask mode. In Quick Mask mode, with the new layer selected (with the nice pattern on it) - choose the Gradient tool.</p>
<p><a href="http://imgplace.com/image/view/8b361b64c9ea67fe133a29e275a3a877" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/5965/8b361b64c9ea67fe133a29e275a3a877.png.th.jpg" border="0" alt="Gradient Tool"></a></p>
<div style="clear: both;"></div>
<p>Drag a gradient from the top of the screen, down to the first horizontal guide (160px down). You&#039;ll have a red gradient, don&#039;t worry about that - we&#039;re in Quick Mask mode and it&#039;s supposed to do that. Now press Q to exit the Quick Mask mode, then press delete. Your pattern should now fade out as it gets closer to the bottom of the header section:</p>
<p><a href="http://imgplace.com/image/view/49e0b218929927ad5cb24462db3d9353" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/7833/49e0b218929927ad5cb24462db3d9353.png.th.jpg" border="0" alt="Gradient Header"></a></p>
<div style="clear: both;"></div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h3>Saving your Slices</h3>
<p>That&#039;s your layout basically done (without any content / images). Now to save the slices for our XHTML layout. Create two new horizontal guides, the first one set with a position of 170px, and the second with a position of 610px. Now, use the slice tool, and create a slice from the top left, across the entire width, and down to the first new horizontal guide (170px down). Create a second slice starting from the left and down at 170px, drag it all the way to the right and down to the second new horizontal guide. Create a third slice with the remaining space. You should have the following:</p>
<p><a href="http://imgplace.com/image/view/5bc07cb2e1a5055daf11726abcea4df3" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/6039/5bc07cb2e1a5055daf11726abcea4df3.png.th.jpg" border="0" alt="Saving Slices"></a></p>
<div style="clear: both;"></div>
<p>Now choose &#039;File > Save for Web &#038; Devices&#039; and save the images. This process will create a folder in your directory you chose to save them in. Within this folder will be your three sliced images. Browse to that folder, and delete the middle image. We don&#039;t need this. Name the header slice &#039;header&#039; and the footer image &#039;footer&#039;. Move both the header and footer images to your web image directory.</p>
<p>Now, back in photoshop, using the Rectangular Marquee tool select from the top left, all the way to the bottom and go in the number of pixels that match the width of your pattern you used earlier from the left edge of the document. Goto Edit > Copy Merged, then click File > New Document and make sure the dimensions are <<em>width of pattern</em>>px by 700px. Paste in the copied image, then File > Save for Web &#038; Devices. Save this image as &#039;main_bg&#039;. This is your main background image. Now, choose the Single Row Marquee Tool, and click once in the middle section of your main document (anywhere that the second slice contains). Do the same as before with the vertical slice&#8230; copy merged, open a new document, paste it in and save for web as &#039;content_bg&#039;.</p>
<p>You should now have 4 main images:</p>
<ul>
<li>header</li>
<li>footer</li>
<li>main_bg</li>
<li>content_bg</li>
</ul>
<h3>Creating the XHTML / CSS</h3>
<p>Firstly, lets set up our directory structure. We will be needing the following:</p>
<ul>
<li>index.html</li>
<li>design.css</li>
<li>folder for images</li>
</ul>
<p>We will be wanting a final directory structure that resembles the following:</p>
<pre>+-my layout/
  |
  +-img/
  | |
  | +- content_bg.png
  | +- footer.png
  | +- header.png
  | +- main_bg.png
  |
  +- design.css
  +- index.html</pre>
<p>Navigate to your root folder for this tutorial (where the files are going to be saved). Create a new folder called <strong>img</strong> and copy your images into it.</p>
<p>Now create the XHTML document (<strong>index.html</strong>). Let&#039;s use the following Dreamweaver default as a nice structure to work from:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc0">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span><br />
<span class="sc2"><a href="http://december.com/html/4/element/html.html"><span class="kw2">&lt;html</span></a> xmlns=<span class="st0">&#034;http://www.w3.org/1999/xhtml&#034;</span><span class="kw2">&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/head.html"><span class="kw2">&lt;head&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/meta.html"><span class="kw2">&lt;meta</span></a> <span class="kw3">http-equiv</span>=<span class="st0">&#034;Content-Type&#034;</span> <span class="kw3">content</span>=<span class="st0">&#034;text/html; charset=utf-8&#034;</span> /<span class="kw2">&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/title.html"><span class="kw2">&lt;title&gt;</span></a></span>My Web2.0 Layout<span class="sc2"><span class="kw2">&lt;/title&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/head&gt;</span></span></p>
<p><span class="sc2"><a href="http://december.com/html/4/element/body.html"><span class="kw2">&lt;body&gt;</span></a></span><br />
<span class="sc2"><span class="kw2">&lt;/body&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/html&gt;</span></span></div>
</div>
<p>Add the following <strong>div</strong> tags between the <strong>BODY </strong>tags:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;wrapper&#034;</span><span class="kw2">&gt;</span></a></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;header&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;content&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;footer&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></div>
</div>
<p>Now it&#039;s time for the CSS. Create the new CSS file (<strong>design.css</strong>) and add the following CSS code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">@charset &quot;utf-8&quot;;</span><br />
<span class="coMULTI">/* CSS Document */</span></p>
<p>body <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">padding</span>: <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-family</span>: <span class="st0">&#034;Century Gothic&#034;</span>, Arial, <span class="kw2">sans-serif</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">color</span>: #333333;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-size</span>: 12px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">text-align</span>: <span class="kw2">center</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/main_bg.png<span class="br0">&#41;</span> <span class="kw2">repeat-x</span> #302a1d;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#wrapper <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">width</span>: 1024px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="kw2">auto</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">text-align</span>: <span class="kw1">left</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#header <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/header.png<span class="br0">&#41;</span> <span class="kw2">no-repeat</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">height</span>: 170px;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#content <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/content_bg.png<span class="br0">&#41;</span> <span class="kw2">repeat-y</span>;<br />
<span class="br0">&#125;</span></p>
<p>#content h1 <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-weight</span>: <span class="kw2">normal</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-size</span>: 36px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">color</span>: #918977;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span> 80px 5px 80px;<br />
<span class="br0">&#125;</span></p>
<p>#content p <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span> 80px 5px 80px;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#footer <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/footer.png<span class="br0">&#41;</span> <span class="kw2">no-repeat</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">height</span>: 90px;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Now, attach the stylesheet to your XHTML document using:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/link.html"><span class="kw2">&lt;link</span></a> <span class="kw3">href</span>=<span class="st0">&#034;design.css&#034;</span> <span class="kw3">rel</span>=<span class="st0">&#034;stylesheet&#034;</span> <span class="kw3">type</span>=<span class="st0">&#034;text/css&#034;</span> <span class="kw3">media</span>=<span class="st0">&#034;screen&#034;</span> /<span class="kw2">&gt;</span></a></span></div>
</div>
<p>anywhere between the <strong>HEAD </strong>tags.</p>
<p>Voila! We&#039;re done!</p>
<h3>Extras</h3>
<p>Play around with this simple layout design, create new images, change colours and edit the CSS. Take a look at my <a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design">final design</a>.</p>
<p>I changed the header image to include a logo and some links, and also added some images to the footer. It seems to be the web2.0 style that you incorporate faint logos at the bottom of your layout.</p>
<p><a href='http://www.mediafire.com/?m1umgjhexzv' title="Download all the files used in this tutorial"><img src="http://edrackham.com/images/download_tut_files.png" alt="Download Tutorial Files" border="0" /></a></p>
<p><a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design"><img src="http://edrackham.com/images/view_it.png" alt="View Final Design" border="0" /></a></p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Online .htpasswd Generator</title>
		<link>http://edrackham.com/apache/online-htpasswd-generator/</link>
		<comments>http://edrackham.com/apache/online-htpasswd-generator/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 13:51:25 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[.htaccess]]></category>

		<category><![CDATA[Apache]]></category>

		<category><![CDATA[Tools]]></category>
<category>generator</category><category>htpasswd</category><category>prevent access</category><category>secure directory</category><category>Tools</category>
		<guid isPermaLink="false">http://edrackham.com/apache/online-htpasswd-generator/</guid>
		<description><![CDATA[Use the following .htpasswd generator to secure your Apache web directories.
Your browser does not support IFRAMES. Please view the generator at http://edrackham.com/tutorials/online-htpasswd-generator/
Make sure you have a .htaccess and .htpasswd file in the directory you want to secure, then add the entries once you&#039;ve generated your password.






]]></description>
			<content:encoded><![CDATA[<p>Use the following .htpasswd generator to secure your Apache web directories.</p>
<p><iframe id="htpasswd_generator" name="htpasswd_generator" width="460" scrolling="no" height="130" frameborder="0" src="http://edrackham.com/tutorials/online-htpasswd-generator/?iframe">Your browser does not support IFRAMES. Please view the generator at http://edrackham.com/tutorials/online-htpasswd-generator/</iframe></p>
<p>Make sure you have a .htaccess and .htpasswd file in the directory you want to secure, then add the entries once you&#039;ve generated your password.</p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/apache/online-htpasswd-generator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Online MD5 Hash Generator</title>
		<link>http://edrackham.com/tools/online-md5-hash-generator/</link>
		<comments>http://edrackham.com/tools/online-md5-hash-generator/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 10:38:41 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Tools]]></category>
<category>MD5 Hash</category><category>PHP</category><category>Tools</category>
		<guid isPermaLink="false">http://edrackham.com/tools/online-md5-hash-generator/</guid>
		<description><![CDATA[Here is a simple MD5 hash generator I created quickly as part of a useful toolset I&#039;m planning to build up.
Your browser doesn&#039;t support IFRAMES. You can see the MD5 hash generator here.
The code to generate an MD5 hash using PHP is simple:

md5&#40;$string_to_convert&#41;;







]]></description>
			<content:encoded><![CDATA[<p>Here is a simple MD5 hash generator I created quickly as part of a useful toolset I&#039;m planning to build up.</p>
<p><iframe frameborder="0" src="http://edrackham.com/tutorials/online-md5-hash-generator/?iframe" height="80px" width="460px" scrolling="no">Your browser doesn&#039;t support IFRAMES. You can see the MD5 hash generator <a href="http://edrackham.com/tutorials/online-md5-hash-generator/" title="Simple Online MD5 Hash Generator">here</a>.</iframe></p>
<p>The code to generate an MD5 hash using PHP is simple:</p>
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/md5"><span class="kw3">md5</span></a><span class="br0">&#40;</span><span class="re0">$string_to_convert</span><span class="br0">&#41;</span>;</div>
</div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/tools/online-md5-hash-generator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Top 10 .htaccess Tips and Tricks</title>
		<link>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/</link>
		<comments>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 00:23:39 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[.htaccess]]></category>

		<category><![CDATA[Apache]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>
<category>.htaccess</category><category>apache</category><category>tips</category><category>tricks</category>
		<guid isPermaLink="false">http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/</guid>
		<description><![CDATA[Custom Error Documents
Creating custom documents gives your site a more professional look, as not only are you providing a &#039;net&#039; to catch unsuspecting visitors when they follow a bad link and such like, but they also allow you to customise the style of the page so you can maintain your basic site design by adding [...]]]></description>
			<content:encoded><![CDATA[<h4>Custom Error Documents</h4>
<p>Creating custom documents gives your site a more professional look, as not only are you providing a &#039;net&#039; to catch unsuspecting visitors when they follow a bad link and such like, but they also allow you to customise the style of the page so you can maintain your basic site design by adding HTML.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># custom error documents</span><br />
<span class="kw1">ErrorDocument</span> <span class="nu0">401</span> /error/<span class="nu0">401</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">403</span> /error/<span class="nu0">403</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">404</span> /error/<span class="nu0">404</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">500</span> /error/<span class="nu0">500</span>.php</div>
</div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h4>Control Access</h4>
<p>Being able to control access to certain areas of your server can be very useful. The following example demonstrates how to only allow access from those connecting from a 192.168.0 LAN IP pool. This could be easily modified to only allow access from a single remote IP address or addresses.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># no nasty crackers in here!</span><br />
<span class="kw1">order</span> <span class="kw1">deny</span>,<span class="kw1">allow</span><br />
<span class="kw1">deny</span> <span class="kw1">from</span> <span class="kw1">all</span><br />
<span class="kw1">allow</span> <span class="kw1">from</span> <span class="nu0">192</span>.<span class="nu0">168</span>.<span class="nu0">0</span>.<span class="nu0">0</span>/<span class="nu0">24</span><br />
<span class="co1"># this would do the same thing..</span><br />
<span class="co1">#allow from 192.168.0 </span><br />
&nbsp;</div>
</div>
<h4>Hide and Deny Files</h4>
<p>Hiding and denying access to files is crucial to servers that have sensitive data held within files that may be accessible via the website(s) on it. The following example demonstrates how to prevent acces to any files ending with .log - and is case insensitive (i.e. .LoG / .lOG / .loG).</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;Files ~ <span class="st0">&#034;^.*<span class="es0">\.</span>([Ll][Oo][Gg])&#034;</span>&gt;<br />
&nbsp;<span class="kw1">Order</span> <span class="kw1">allow</span>,<span class="kw1">deny</span><br />
&nbsp;<span class="kw1">Deny</span> <span class="kw1">from</span> <span class="kw1">all</span><br />
&nbsp;<span class="kw1">Satisfy</span> <span class="kw1">All</span><br />
&lt;/Files&gt;</div>
</div>
<h4>Basic Rewriting</h4>
<p>I have written a <a href="http://edrackham.com/apache/beginners-mod_rewrite-tutorial/" title="mod_rewrite tutorial">mod_rewrite tutorial</a>, but this is worth a mention as a top 10 tip for .htaccess files as it&#039;s becoming more and more commonly used these days - primarily for SEO purposes.</p>
<p>This example will redirect a request for <strong>http://edrackham.com/page_one.htm</strong> to <strong>http://edrackham.com/page_one.php</strong>. The <em>r=301</em> tells apache to send a proper HTTP <em>Permanently Moved</em> redirection (301), which will update the address bar in the browser window to show &#039;page_one.php&#039;. Without this, you&#039;d still see &#039;page_one.htm&#039; even though you&#039;re seeing a PHP page. This helps SEO, as spiders and search engines will update their listings to reflect the PHP versions.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>\.htm$ http://edrackham.com/$<span class="nu0">1</span>.php <span class="br0">&#91;</span>r=<span class="nu0">301</span>,nc<span class="br0">&#93;</span></div>
</div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h4>Shorter URLs</h4>
<p>Shorter URLs are beneficial, as visitors that persist in typing full URLs won&#039;t have to type as much, and they&#039;re more memorable. Do they benefit SEO, even though the full URL contains the same keywords? I don&#039;t know, maybe someone can tell me.</p>
<p>This example will rewrite a page requested as <strong>http://edrackham.com/files/code/apache.zip</strong> to <strong>http://edrackham.com/download.php?type=code&amp;file=apache</strong>.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^<span class="kw1">files</span>/<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>/<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>.zip download.php?type=$<span class="nu0">1</span>&amp;file=$<span class="nu0">2</span> <span class="br0">&#91;</span>nc<span class="br0">&#93;</span></div>
</div>
<h4>Prevent Hotlinking</h4>
<p>Preventing hotlinking can reduce bandwidth, by disallowing other websites from displaying images hosted on your server. The following rule basically says that if the referer is NOT edrackham.com, run the following rule. The rule (on the next line) says that if the request is for a .gif, .jpg or.png then redirect the visitor to http://edrackham.com/img/hotlink_f_o.png. I&#039;ll leave you to work out what the &#039;f_o&#039; stands for.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="co1"># no hot-linking</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">On</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_REFERER<span class="br0">&#125;</span> !^$<br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_REFERER<span class="br0">&#125;</span> !^http://<span class="br0">&#40;</span>www\.<span class="br0">&#41;</span>?edrackham\.com/ <span class="br0">&#91;</span>nc<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> .*\.<span class="br0">&#40;</span>gif|jpg|png<span class="br0">&#41;</span>$ http://edrackham.com/img/hotlink_f_o.png <span class="br0">&#91;</span>nc<span class="br0">&#93;</span></div>
</div>
<h4>Hiding Page Extension</h4>
<p>Similar to the mod_rewrite code above, this will redirect a request for <strong>product-<em>3</em>.html</strong> to <strong>products.php?id=<em>3</em></strong>. As we&#039;re not using <em>r=301</em>, the requested page will remain in the browser&#039;s address bar.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^product-<span class="br0">&#40;</span><span class="br0">&#91;</span><span class="nu0">0</span>-<span class="nu0">9</span><span class="br0">&#93;</span>+<span class="br0">&#41;</span>\.html$ products.php?id=$<span class="nu0">1</span></div>
</div>
<h4>Ban Selected User Agents</h4>
<p>In my opinion, it&#039;d be ace to block all requests from a Microsoft user agent, but alas, that wouldn&#039;t be too cool as some people are still hell-bent on using a non-standards compliant browser. Having said that, Microsoft is making their new <a href="http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/" title="Microsoft to release standards compliant browser. Yes really!">IE8 release standards compliant</a> by default.</p>
<p>The following provides some examples for blocking requests to your server from certain user agents.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#####################################</span><br />
<span class="co1"># Deny Useragents</span><br />
<span class="co1">#####################################</span></p>
<p><span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^FrontPage <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Java.* <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Microsoft.URL <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^MSFrontPage <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Offline.Explorer <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^<span class="br0">&#91;</span>Ww<span class="br0">&#93;</span>eb<span class="br0">&#91;</span>Bb<span class="br0">&#93;</span>andit <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Zeus <span class="br0">&#91;</span>NC<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> ^.*$ - <span class="br0">&#91;</span>F<span class="br0">&#93;</span></div>
</div>
<h4>Making Other Filetypes Executable</h4>
<p>Ever wanted to make your site look like it runs off a new language such as .w00t files? Well you can with .htaccess! Adding this neat one-liner, you can request .w00t files, which will be served and interpreted as .php type files.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">AddType</span> application/x-httpd-php .w00t</div>
</div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h4>Force Media Downloads</h4>
<p>Sometimes, when clicking on media files, the browser wants to play or stream it directly from itself. Using the following rules, media files (.avi/.mpg/.wmv/.mp3 in this example) will provide a download dialog box instead.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># instruct browser to download multimedia files</span><br />
<span class="kw1">AddType</span> application/octet-stream .avi<br />
<span class="kw1">AddType</span> application/octet-stream .mpg<br />
<span class="kw1">AddType</span> application/octet-stream .wmv<br />
<span class="kw1">AddType</span> application/octet-stream .mp3</div>
</div>
<h4>Require SSL</h4>
<p>Sometimes you will require an SSL connection. This following snippet will do just that!</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># require SSL</span><br />
SSLOptions +StrictRequire<br />
SSLRequireSSL<br />
SSLRequire %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> eq <span class="st0">&#034;domain.tld&#034;</span><br />
<span class="kw1">ErrorDocument</span> <span class="nu0">403</span> https://domain.tld</p>
<p><span class="co1"># require SSL without mod_ssl</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTPS<span class="br0">&#125;</span> !=<span class="kw2">on</span> <span class="br0">&#91;</span>NC<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> ^.*$ https://%<span class="br0">&#123;</span>SERVER_NAME<span class="br0">&#125;</span>%<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> <span class="br0">&#91;</span>R,L<span class="br0">&#93;</span></div>
</div>
<p>Sources:<br />
http://corz.org/serv/tricks/htaccess.php<br />
http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html<br />
http://expressproducts.net/htaccess.htm<br />
http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#usa4<br />
http://phpsecurity.wordpress.com/2007/12/22/htaccess-tips-and-tricks/</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get Random Row with MySQL Without ORDER BY RAND()</title>
		<link>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/</link>
		<comments>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 12:12:24 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Featured]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[fast]]></category>

		<category><![CDATA[random row]]></category>
<category>fast</category><category>MySQL</category><category>random row</category>
		<guid isPermaLink="false">http://edrackham.com/mysql/get-random-row-with-mysql-without-rand/</guid>
		<description><![CDATA[This is an update to a previous post of mine which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:

SELECT &#60;COLUMN&#62; FROM &#60;TABLE&#62; AS r1
JOIN &#40;SELECT ROUND&#40;
&#160; RAND&#40; &#41; * &#40;
&#160; &#160; SELECT MAX&#40; id &#41; FROM &#60;TABLE&#62;&#41;
&#160; &#41; AS [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update to a <a href="http://edrackham.com/php/get-random-row-with-mysql/" title="Slower, but useful for smaller tables">previous post of mine</a> which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">SELECT</span> &lt;COLUMN&gt; <span class="kw1">FROM</span> &lt;TABLE&gt; <span class="kw1">AS</span> r1<br />
<span class="kw1">JOIN</span> <span class="br0">&#40;</span><span class="kw1">SELECT</span> ROUND<span class="br0">&#40;</span><br />
&nbsp; RAND<span class="br0">&#40;</span> <span class="br0">&#41;</span> * <span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="kw1">SELECT</span> MAX<span class="br0">&#40;</span> id <span class="br0">&#41;</span> <span class="kw1">FROM</span> &lt;TABLE&gt;<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#41;</span> <span class="kw1">AS</span> id<br />
<span class="br0">&#41;</span> <span class="kw1">AS</span> r2<br />
<span class="kw1">WHERE</span> r1.id &gt;= r2.id<br />
<span class="kw1">ORDER</span> <span class="kw1">BY</span> r1.id <span class="kw1">ASC</span><br />
<span class="kw1">LIMIT</span> <span class="nu0">1</span>;</div>
</div>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Replace:</p>
<ul>
<li><strong>&lt;COLUMN&gt;</strong> with the name of the column(s) you wish to retrieve</li>
<li><strong>&lt;TABLE&gt;</strong> with the name of the table you wish to retrieve the data from</li>
</ul>
<p>I&#039;ve tested this with a table with over 660,000 records, and got a response in 0.0200 seconds, whereas with ORDER BY RAND() i got a response in 2.1599 seconds.</p>
<h4>Total Number of Rows:</h4>
<p><img src="http://edrackham.com/images/posts/num-rows.gif" alt="Cardinality" style="border:1px solid #ccc" /></p>
<h4>Old Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-old-query.gif" alt="Old Method" style="border:1px solid #ccc" /></p>
<h4>New Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-new-query.gif" alt="New Method" style="border:1px solid #ccc" /></p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Standards Compliant Internet Explorer (IE8)</title>
		<link>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/</link>
		<comments>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 21:36:00 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Web Standards]]></category>

		<category><![CDATA[IE8]]></category>
<category>IE8</category><category>Web Standards</category>
		<guid isPermaLink="false">http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/</guid>
		<description><![CDATA[We’ve decided that IE8 will, by default, interpret web content in the most standards compliant way it can. This decision is a change from what we’ve posted previously.
Don your glad rags and party hats, it&#039;s time to celebrate! Microsoft have announced that their new interoperable release of Internet Explorer (IE8) will be standards compliant by [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>We’ve decided that IE8 will, by default, interpret web content in the most standards compliant way it can. This decision is a change from what we’ve posted previously.</p></blockquote>
<p>Don your glad rags and party hats, it&#039;s time to celebrate! Microsoft have announced that their new interoperable release of <a href="http://blogs.msdn.com/ie/archive/2008/03/03/microsoft-s-interoperability-principles-and-ie8.aspx" title="Let's hope so...">Internet Explorer (IE8) will be standards compliant by default</a>.</p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Their explaination for change still hints at their stubborness though: <em>&#034;While we do not believe any current legal requirements would dictate which rendering mode a browser must use, this step clearly removes this question as a potential legal and regulatory issue.&#034;</em>.</p>
<h3>So what does this mean for us as designers?</h3>
<p>Don&#039;t misconceive me - I&#039;m not primarily a designer, but I do design all sites I build &#8230;in pure CSS. This change will mean that we should know that our designs will render the same in all mainstream browsers such as FireFox, Opera, Safari and of course IE8 (provided we use valid CSS1, 2 or 3 [when fully supported] code). The days of running both FireFox and IE6/7, uploading your new CSS file and hitting F5 to find that the bug you just fixed in IE6/7 has now broken something else layout-wise should now be gone.</p>
<p>IE8 will support standards compliant mode as default, but will be backward compatible with our already &#039;IE Bug-Fixed&#039; CSS files. So, to save us backtracking to make our previously written CSS files - which have no doubt taken us hours upon hours to write thanks to IE7- rendering modes - we can insert a meta tag into IE8 to set it to &#034;Quirks Mode&#034; for this exact purpose.</p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<h3>A final note</h3>
<p>All in all, I don&#039;t have much confidence in Microsoft and the web. This confidence decreases even more after hearing any one of Steve Ballmer&#039;s semitars, especially the one about Microsoft winning the web. In my opinion, they never will, but this is a fantastic step in the right direction which leads me to say two things; Well done Microsoft, and two, Let&#039;s get used to the days of IE7-.</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Guilt Trip Album Release Gig</title>
		<link>http://edrackham.com/asides/guilt-trip-album-release-gig/</link>
		<comments>http://edrackham.com/asides/guilt-trip-album-release-gig/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 00:45:31 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<category><![CDATA[Music]]></category>

		<category><![CDATA[Guilt Trip]]></category>

		<category><![CDATA[Live]]></category>

		<guid isPermaLink="false">http://edrackham.com/asides/guilt-trip-album-release-gig/</guid>
		<description><![CDATA[
Wow. This was definately a gig to remember! I&#039;ve seen these guys a few times, but the amount of effort they&#039;ve put into the release of their album has been phenomenal. The energy on stage was amazing, the music was spot on and everyone in the venue were on their feet.
I really hope these guys [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://edrackham.com/images/posts/guilt-trip.jpg" alt="Guilt Trip's Album Release Gig" /><br />
Wow. This was definately a gig to remember! I&#039;ve seen these guys a few times, but the amount of effort they&#039;ve put into the release of their album has been phenomenal. The energy on stage was amazing, the music was spot on and everyone in the venue were on their feet.</p>
<p>I really hope these guys make it. They deserve it.</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/asides/guilt-trip-album-release-gig/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get Random Row with MySQL</title>
		<link>http://edrackham.com/php/get-random-row-with-mysql/</link>
		<comments>http://edrackham.com/php/get-random-row-with-mysql/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 00:51:31 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP]]></category>
<category>MySQL</category><category>PHP</category><category>Tutorial</category>
		<guid isPermaLink="false">http://edrackham.com/php/get-random-row-with-mysql/</guid>
		<description><![CDATA[UPDATE: Please see my newer atricle on how to retrieve a random row, faster, without RAND().






This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named &#039;quotes&#039; as shown below. In this post, I will aim to teach you how to use PHP [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> Please see my newer atricle on <a href="http://edrackham.com/mysql/get-random-row-with-mysql-without-rand/" title="Blink, and you'll miss it!">how to retrieve a random row, faster, without RAND()</a>.</p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named &#039;quotes&#039; as shown below. In this post, I will aim to teach you how to use PHP to pull random quotes from a MYSQL table of quotes. This can be easily extended to pull a random banner as will be explained at the end of the post.</p>
<p>Let&#039;s firstly assume we have a MySQL table similar to the following:</p>
<pre>+----+------------------------------------------------+
| id | quote                                          |
+----+------------------------------------------------+
| 1  | I know Karate... and many other Chinese words! |
+----+------------------------------------------------+
| 2  | w00t this is geeky                             |
+----+------------------------------------------------+
| 3  | You're CLINICALLY MENTAL!                      |
+----+------------------------------------------------+</pre>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Now, in your PHP code, we need to:</p>
<ol>
<li>Build a suitable MySQL query to obtain a random result from the &#039;quotes&#039; table.</li>
<li>Store the result of the query to be used in the HTML somewhere.</li>
<li>Output the result in the HTML somewhere.</li>
</ol>
<p>So, for step one we&#039;d use something like the following:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sSQLQuery</span> = <span class="st0">&#034;SELECT quote FROM quotes ORDER BY RAND() LIMIT 1&#034;</span>;<br />
<span class="re0">$aResult</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sSQLQuery</span><span class="br0">&#41;</span>;<br />
<span class="re0">$aRow</span> = <a href="http://www.php.net/mysql_fetch_array"><span class="kw3">mysql_fetch_array</span></a><span class="br0">&#40;</span><span class="re0">$aResult</span>, MYSQL_ASSOC<span class="br0">&#41;</span>;<br />
<span class="re0">$sQuoteOfTheDay</span> = <span class="re0">$aRow</span><span class="br0">&#91;</span><span class="st0">&#039;quote&#039;</span><span class="br0">&#93;</span>;</div>
</div>
<p>There, the variable &#039;$sQuoteOfTheDay&#039; now has the value of our randomly pulled quote. Let&#039;s just analyse each line of the code above to see what it does.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sSQLQuery</span> = <span class="st0">&#034;SELECT quote FROM quotes ORDER BY RAND() LIMIT 1&#034;</span>;</div>
</div>
<p>This line stores the MySQL query we&#039;re going to use against the database. It says, in laymans terms, &#034;Select just one random value of the quote field from the table named quotes&#034;. All this line does though is store the query into the variable &#039;$sSQLQuery&#039;.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$aResult</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sSQLQuery</span><span class="br0">&#41;</span>;</div>
</div>
<p>This line runs the MySQL query, storing the result of running the query in the variable &#039;$aResult&#039;. It&#039;s important that we store the result of the mysql_query in a variable, as the result of running a successful MySQL query using PHP&#039;s function &#039;mysql_query&#039; doesn’t return a nicely formatted array that we can necessarily use.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$aRow</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$aResult</span><span class="br0">&#41;</span>;</div>
</div>
<p>This is probably the hardest line for me to explain. Firstly, many of you may have seen a similar line like this used in a &#039;while&#039; loop. However, our MySQL query used the &#039;LIMIT 1&#039; string, so we know we’re only going to get ONE result, hence no need for a loop. The function &#039;mysql_fetch_assoc&#039; takes one parameter: the result of the successful &#039;mysql_query&#039; which as we know is &#039;$aResult&#039;. My biggest tip here is to use the &#039;assoc&#039; method wherever possible, as it creates the array in such a way that we can reference each element by the column name, not a number. This is particularly useful if you ever update the MySQL table to have more columns.</p>
<p>Anyway, this line basically says &#039;Fill the variable &#039;$aRow&#039; with the CURRENT row of the returned query&#039;. We know that the CURRENT row of the returned query is the ONLY row, hence (again) the lack of a loop. As the result of our query would return something like:</p>
<pre>+-----------------------------------------------+
| quote                                         |
+-----------------------------------------------+
| You're CLINICALLY MENTAL!                     |
+-----------------------------------------------+</pre>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Our variable (or array) would literally look something like:</p>
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/array"><span class="kw3">Array</span></a> <span class="br0">&#40;</span> <span class="st0">&#034;quote&#034;</span> = <span class="st0">&#034;You&#039;re CLINICALLY MENTAL!&#034;</span> <span class="br0">&#41;</span></div>
</div>
<p>Which leads us on to our last line:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sQuoteOfTheDay</span> = <span class="re0">$aRow</span><span class="br0">&#91;</span><span class="st0">&#039;quote&#039;</span><span class="br0">&#93;</span>;</div>
</div>
<p>Which just assigns the value of &#039;$aRow[&#039;quote&#039;]&#039; to the variable &#039;$sQuoteOfTheDay&#039;. In other words, &#039;$sQuoteOfTheDay&#039; now has the value of a random quote pulled from the database of quotes.</p>
<p>To use this in an HTML page, we would simply just use this (AFTER the above code has grabbed the random quote from the DB for us):</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?</span>= <span class="re0">$sQuoteOfTheDay</span>; <span class="kw2">?&gt;</span></div>
</div>
<p>Which will output the quote of the day somewhere in the HTML code.</p>
<p>As I said at the beginning, this can be extended easily to pull an image for a banner by simply changing the quotes table to store image paths such as &#039;images/my_image.png&#039; which can then be pulled in the same way, and then output similar to the following:</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;img src=<span class="st0">&#034;&lt;?= $sImageOfTheDay; ?&gt;&#034;</span> alt=<span class="st0">&#034;My Image&#034;</span> /&gt;</div>
</div>
<p>Obviously we changed the variable name here to $sImageOfTheDay just to keep things constant.</p>
<p>Hope this has helped someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/get-random-row-with-mysql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Class Tutorial</title>
		<link>http://edrackham.com/php/php-class-tutorial/</link>
		<comments>http://edrackham.com/php/php-class-tutorial/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 00:39:09 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>Classes</category><category>PHP</category><category>Tutorial</category>
		<guid isPermaLink="false">http://edrackham.com/php/php-class-tutorial/</guid>
		<description><![CDATA[I’m not sure how to start this one… It can be quite difficult to understand PHP classes at first, but hopefully I’ll make everything seem easy! Let&#039;s just get stuck in shall we…
Brief overview…
Ok so you’re actually reading this brief overview? You must be serious…
PHP classes can be used to group together a set of [...]]]></description>
			<content:encoded><![CDATA[<p>I’m not sure how to start this one… It can be quite difficult to understand PHP classes at first, but hopefully I’ll make everything seem easy! Let&#039;s just get stuck in shall we…</p>
<h1>Brief overview…</h1>
<p>Ok so you’re actually reading this brief overview? You must be serious…</p>
<p>PHP classes can be used to group together a set of ‘like’ functions used within a bigger application. Their main advantage is the fact that you can edit the particular class function, or functions and make a site-wide change. Classes also help give you a more structured approach to programming, and those that like to hack with some GPL released web applications will have a much better understanding of the workings of them.</p>
<p>This may not be the best example of explaining why to use classes in PHP, but it’s an example of how to use them.</p>
<p>Let’s start by creating a new file called time.php. Within this file, let’s add some code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="re0">$sTime</span> = <a href="http://www.php.net/gmdate"><span class="kw3">gmdate</span></a><span class="br0">&#40;</span><span class="st0">&#034;d-m-Y H:i:s&#034;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="st0">&#039;The time is: &#039;</span> . <span class="re0">$sTime</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
<p>This will simply assign the current date and time to the variable <strong>$sTime</strong> and then print the string &#039;The time is&#039; with the variable value at the end (e.g. The time is: 09-02-2007 21:42:28)</p>
<p>How would we do this, using a class? Well there&#039;s many ways, however I would recommend using the class file to generate the time, then use the acutal &#039;action page&#039; (time.php) to output the time. Let&#039;s create our class file!</p>
<h1>Get in class!</h1>
<p>Create a new file (keep it in the same directory for this tutorial). Let’s call it <strong>class.Time.php</strong>. Add the following code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw2">class</span> <a href="http://www.php.net/time"><span class="kw3">Time</span></a> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">function</span> GenerateCurrentTime<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$sTime</span> = <a href="http://www.php.net/gmdate"><span class="kw3">gmdate</span></a><span class="br0">&#40;</span><span class="st0">&#034;d-m-Y H:i:s&#034;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$sTime</span>;<br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Lets do this line by line… The first line, <strong>class Time {</strong>,declares the class as open (exactly the same as a function in PHP, but without the brackets in this case). The next line declares a new function. The difference here is that it exists ONLY within the scope of the class (e.g. it&#039;s built WITHIN the class). We then generate the time as we did before, assigning it to the variable $sTime and then return the value of this variable. The function then closes, followed by the class closure (the squiggly brackets &#039;}&#039;). Note that our class needs to also be wrapped in php tags (<?php … ?>).</p>
<p>Now open the original file, time.php, and change the code to match the following:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw1">include</span> <span class="br0">&#40;</span><span class="st0">&#039;class.Time.php&#039;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$oTime</span> = <span class="kw2">new</span> <a href="http://www.php.net/time"><span class="kw3">Time</span></a>;<br />
<span class="re0">$sTime</span> = <span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="st0">&#039;The time is: &#039;</span> . <span class="re0">$sTime</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Now, the first line here includes the time class file (<strong>include (&#039;class.Time.php&#039;);</strong>). We must include all the class files we wish to take advantage of, otherwise how the hell would PHP know about these files?</p>
<p>The next line, $oTime = new Time, creates the class object and stores it in the variable $oTime. Notice, to store the class in an object variable, we use <em>VARIABLE = NEW CLASSNAME</em>. <em>VARIABLE</em> can be anything, then there must be an equals sign &#039;=&#039;. <em>NEW </em>must use &#039;new&#039; or &#039;&#038;new&#039;, and the <em>CLASSNAME </em>must match the name of the class. In this case, the name of the class is Time (case sensitive - as PHP is throughout). The class name is &#039;Time&#039; because we created the class using <strong>class Time {</strong>.</p>
<p>If we had used <strong>class HelloWorld {</strong>, as you can guess, the class name would be &#039;HelloWorld&#039;.</p>
<p>Anyway… now we&#039;ve created our class, we have also included it within the page we want to make use of it. Not only that, we have ALSO initalised our class by defining it in an object variable - $oTime.</p>
<p>So, the next line:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sTime</span> = <span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p>This simply assings the variable $sTime with the result of the function GenerateCurrentTime() within the Time class. How does it do this? Simple… We want to use the function GenerateCurrentTime() within the class $oTime so we simply us:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</div>
<p>This tells PHP exactly what we want to do. The &#039;->&#039; explains to PHP that the prefix (in this case $oTime, which we know holds the class object) is the parent of the latter (again, in this case the latter is GenerateCurrentTime()). So it basically means, run GenerateCurrentTime() within the $oTime class. Thus assigning whatever is returned by the function GenerateCurrentTime() to the variable $sTime.</p>
<p>The last line does what we did from scratch… print out the results with the prefixed string &#039;The time is&#039;.</p>
<p>In the next installment, we will discuss what $this-> means, and how it can be immensly beneficial to you to use classes!</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/php-class-tutorial/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
