<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="http://feedproxy.google.com/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feedproxy.google.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Doing My Best... a Web Developers Blog</title>
	
	<link>http://www.iwilldomybest.com</link>
	<description>Ranging from PHP &amp; MySQL to Random Crap from the internet, I got it all here.</description>
	<pubDate>Mon, 05 Jan 2009 11:09:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feedproxy.google.com/DoingMyBestAWebDevelopersBlog" type="application/rss+xml" /><item>
		<title>Modrewrite and Short Urls - What you really want to know.</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/P_fGNDuWKCQ/</link>
		<comments>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 11:07:44 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[mod rewrite]]></category>

		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=77</guid>
		<description><![CDATA[I recently opened up an old .htaccess and I was struck with the memory of how much it sucked trying to Google search for some real, working, answers on making short urls.
So here you go, my quick tip on what you really want to know about mod_rewrite.

If you want an actual explanation of what is [...]]]></description>
			<content:encoded><![CDATA[<p>I recently opened up an old <a title="WikiPedia - Htaccess" href="http://en.wikipedia.org/wiki/Htaccess" target="_blank">.htaccess</a> and I was struck with the memory of how much it sucked trying to Google search for some real, working, answers on making short urls.</p>
<p>So here you go, my quick tip on what you really want to know about <a title="ApacheDocs - Mod_rewrite" href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" target="_blank">mod_rewrite</a>.</p>
<p><span id="more-77"></span></p>
<p>If you want an actual explanation of what is going on here it&#8217;s at the bottom.</p>
<p><strong>Solution 1:</strong></p>
<p><code>File: .htaccess</code></p>
<pre>Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) /index.php [L]</pre>
<p><code>File: index.php</code><br />
<code><br />
&lt;?php<br />
$urlArray = explode("/",$_SERVER['REQUEST_URI']);<br />
array_shift($urlArray); // Gets rid of the blank first param.<br />
?&gt;<br />
</code></p>
<p>Now you have an array with all of your parts, and you can map them accordingly.</p>
<p><strong>Solution 1.a (more elegant):</strong><br />
<code>File: .htaccess</code></p>
<pre>&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;</pre>
<p>That version just checks to make sure the module is installed.</p>
<p><strong>Solution 2:</strong><br />
If you have just a couple of pages that you want to look prettier:</p>
<p><code>File: .htaccess</code></p>
<pre>Options +FollowSymLinks
RewriteEngine on
RewriteRule ^home$ index.php
RewriteRule ^about$ about.php</pre>
<p>And you just keep adding <code>RewriteRule</code>&#8217;s for each page. This is really only helpful when you just have a set of static looking pages for a site.</p>
<p><strong>Explanation:</strong></p>
<dl>
<dt>Options +FollowSymLinks</dt>
<dd>Tells Apache to follow sym links (usually on anyways&#8230;)</dd>
<dt>RewriteEngine on</dt>
<dd>Tells apache to turn on the RewriteEngine for this folder</dd>
<dt>RewriteCond %{REQUEST_FILENAME} !-f</dt>
<dd>Read this as: Condtion, If the file we&#8217;re requesting is not a file&#8230;</dd>
<dt>RewriteCond %{REQUEST_FILENAME} !-d</dt>
<dd>Read this as: Condtion, If the file we&#8217;re requesting is not a directory&#8230;</dd>
<dt>RewriteRule . /index.php [L]</dt>
<dd>Then Rewrite this url to index.php ([L] forces it to be the last redirect)</dd>
</dl>

<p><a href="http://feedads.googleadservices.com/~a/wj87xdvh2eIC6tghfOyHBzW7-ZY/a"><img src="http://feedads.googleadservices.com/~a/wj87xdvh2eIC6tghfOyHBzW7-ZY/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/P_fGNDuWKCQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/</feedburner:origLink></item>
		<item>
		<title>Professional PHP</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/mi_y8Ky-2eE/</link>
		<comments>http://www.iwilldomybest.com/2009/01/professional-php/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 16:05:18 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Development]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=61</guid>
		<description><![CDATA[It&#8217;s important to remember what sets a professional PHP developer apart from the pack that floods your average help channel.
Too often I run into reviewing or helping a &#8220;professional&#8221; developer, and I can&#8217;t help but mutter &#8220;you&#8217;re doing it wrong&#8230;&#8221;

I feel the most important attribute that separates one developer from another is when they write [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s important to remember what sets a professional PHP developer apart from the pack that floods your average help channel.</p>
<p>Too often I run into reviewing or helping a &#8220;professional&#8221; developer, and I can&#8217;t help but mutter &#8220;you&#8217;re doing it wrong&#8230;&#8221;</p>
<p><span id="more-61"></span></p>
<p>I feel the most important attribute that separates one developer from another is when they write for usability and maintainability.</p>
<p>So let&#8217;s take a look at some extremely simple steps you can take to make your project&#8217;s code more flexible.</p>
<p>1. For the love of all that there is, seperate your header and footer files. Yes, I&#8217;m still seeing this happen, often. All content that is above your generated page needs to go into a header file, and all the content below it into a footer file. So when you need to modify one line, you do it only once.</p>
<pre>&lt;?php
require_once(dirname(__FILE__).'/includes/header.php');
?&gt;
&lt;div id='content'&gt;
&lt;?php
	// script runs
?&gt;
&lt;/div&gt;
&lt;?php
require_once(dirname(__FILE__).'/includes/footer.php');
?&gt;</pre>
<p>2. Create a function to generate your navigation. And when I say generate, I mean you give it some flexibility as well. This can be done even with the smallest of sites. Example:</p>
<pre>&lt;?php
$site_pages = array();
$site_pages[] = array('text' =&gt; 'home', 'link' =&gt; 'home.php');
$site_pages[] = array('text' =&gt; 'about', 'link' =&gt; 'about.php');
$site_pages[] = array('text' =&gt; 'partner', 'link' =&gt; 'http://www.example.domain.com/');

function buildNav($links)
{
	$output = '';
	foreach($links as $page)
	{
		$output .= "&lt;a href=\"{$page['link']}\" title=\"{$page['text']}\"&gt;{$page['text']}&lt;/a&gt;\n";
	}
 	return $output;
}
?&gt;</pre>
<p>The example above could easily be modified to allow optional values to the array, like <code>'enabled' =&gt; false</code> to turn off a link. Or you could define a link &#8220;template&#8221;, and use <code>str_replace()</code> to substitute values.</p>
<p>This means if you, or the customer (with any know how) can quickly update the links at any time. For more advanced sites/projects this can obviously become more complicated, but it saves even more time.</p>
<p>3. If you&#8217;re not going to use OOP, at least use functions. Any common task or specific sequence should be placed in it&#8217;s own function. An example would be our navigation function from #2. Another example would be running a query for a specific item. If you ever need to modify your table structure you&#8217;ll regret having to hunt down all of your inline queries.</p>
<p>4. When you create &#8216;admin&#8217; features, take the 5 minutes to create a function that actually checks if the person accessing that &#8220;super hidden&#8221; directory filled with scripts that just accept anything.</p>
<p>I&#8217;ve seen this happen even on large global community sites.</p>
<p>Some developers will stuff their admin scripts in a folder such as /admin/, and just assume that if data is posted there then it&#8217;s ok.</p>
<p>The least you should do is place a session check, and place it in a function.</p>
<pre>&lt;?php
function isAdmin()
{
	if(!isset($_SESSION['user_name']) || !isset($_SESSION['user_id']))
	{
		return false;
	}
	else
	{
		$sql = "SELECT COUNT(*) as cnt FROM user_table WHERE user_id = ".intval($_SESSION['user_id']);
		// do the query, check it, etc.
		return true;
	}
}
?&gt;</pre>
<p>Then when it comes time to run your script, simply:</p>
<pre>&lt;?php
if(isAdmin() === false)
{
	die('Log back in');
}
?&gt;</pre>
<p>5. Create a wrapper for handling escape strings. If you&#8217;re not using a database class (like PDO) to handle this, you&#8217;ll need to do this.</p>
<p>Just assume that your client could have their PHP configuration change, or they change hosts, or any possible combination of changes take place.</p>
<p>Create a simple wrapper that will check of magic quotes, and escape for your database insert.</p>
<pre>&lt;?php
function cleanString($input)
{
	if(get_magic_quotes_gpc())
	{
		$input = stripslashes($input);
	}
	$output = mysql_real_escape_string(trim($input));

	return $output;
}
?&gt;</pre>
<p>6. Create a configuration file so you can update common yet critical variables. An example of this would be paths. Your system quickly gains adaptability if you just create a defines.php file, and place in there your simple variables.</p>
<p>The overall approach you should have to any project you take is that you should use an establish tool chain you have developed. It doesn&#8217;t take much time or effort to create a simple set of classes that can handle just about any thing you need to create. If you wish to use functions, you can do the same. The idea is that you write once, and write it in such a manner that you can tweak it later on.</p>

<p><a href="http://feedads.googleadservices.com/~a/GC7lK74TnW-AMZ0Am9wNBugem9s/a"><img src="http://feedads.googleadservices.com/~a/GC7lK74TnW-AMZ0Am9wNBugem9s/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/mi_y8Ky-2eE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/01/professional-php/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/01/professional-php/</feedburner:origLink></item>
		<item>
		<title>Google Speaks on Net Neutrality and Benefits of caching</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/78sg2CKV_kk/</link>
		<comments>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 04:15:13 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[caching]]></category>

		<category><![CDATA[cdn]]></category>

		<category><![CDATA[edge]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[net]]></category>

		<category><![CDATA[neutrality]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=69</guid>
		<description><![CDATA[In this post on the google blog,http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html , Google speaks about how people are confused on the net neutrality and the use of edge caching.
I find it interesting that someone could take the usage of CDN&#8217;s as an act of an un neutral  web.
The act of handling certain traffic as more important than other traffic [...]]]></description>
			<content:encoded><![CDATA[<p>In this post on the google blog,<a title="http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html" href="http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html" target="_blank">http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html</a> , Google speaks about how people are confused on the net neutrality and the use of edge caching.</p>
<p>I find it interesting that someone could take the usage of CDN&#8217;s as an act of an un neutral  web.</p>
<p>The act of handling certain traffic as more important than other traffic is the act of an un neutral web. Developers should consider these words carefully.</p>

<p><a href="http://feedads.googleadservices.com/~a/9_D-6p6-6tqkXaLwt4iQP-uvCOg/a"><img src="http://feedads.googleadservices.com/~a/9_D-6p6-6tqkXaLwt4iQP-uvCOg/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/78sg2CKV_kk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/</feedburner:origLink></item>
		<item>
		<title>Screen Scraping made too easy</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/exHmjufJ1_Y/</link>
		<comments>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 08:40:27 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[screen scrape]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=63</guid>
		<description><![CDATA[Recently I had some free time and I decided I wanted to automate some common tasks of mine. And let me tell you honestly, I hate having to do screen scraping. It&#8217;s an annoying, tedious task. Making regex for this, and for that, and then to find out my hours were wasted as that regex [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had some free time and I decided I wanted to <a title="WikiPedia - Automation" href="http://en.wikipedia.org/wiki/Automation" target="_blank">automate</a> some common tasks of mine. And let me tell you honestly, I hate having to do screen scraping. It&#8217;s an annoying, tedious task. Making regex for this, and for that, and then to find out my hours were wasted as that regex won&#8217;t work on another site.</p>
<p>That&#8217;s a thing of the past.</p>
<p><span id="more-63"></span></p>
<p>I&#8217;m super excited about this find. Maybe I&#8217;m the last to discover it, but it&#8217;s just too awesome to pass up.</p>
<p>The project is called: <a title="PHP Simple HTML DOM Parser" href="http://simplehtmldom.sourceforge.net/" target="_blank">PHP Simple HTML DOM Parser</a>.</p>
<p>Literally, this takes almost all of the magic out of screen scraping. Here&#8217;s an example from a quick and dirty login and grab my stats for <a title="e-Sports Entertainment" href="http://esportsea.com" target="_blank">ESEA</a>.</p>
<pre>require_once('simple_html_dom.php'); // get our class

define('COOKIE_JAR','./cookie/cookie'); // cookie jar for cURL
/**
* We need to set up our referrer and user agent, for cURL
**/
$referrer = "http://www.esportsea.com/";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4";
/**
* str = our direct link to our user page
**/
$str = "http://www.esportsea.com/users/&lt;your user id&gt;";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$str);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $referrer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_JAR);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_JAR);
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
$result = curl_exec ($ch);
curl_close ($ch);
// done with cURL
$html = new simple_html_dom(); // create our HTML object

$html-&gt;load($result);

$pug_stats = $html-&gt;find('#body-matches-pug table tr'); // load up pug stats

// this loops through each &lt;tr&gt;
$output = array();
foreach($pug_stats as $stat)
{
	$row['game'] 	= trim($stat-&gt;find('img',0)-&gt;title);
	$row['link'] 	= trim($stat-&gt;find('a',0)-&gt;href);
	$row['score']	= trim($stat-&gt;find('a',0)-&gt;plaintext);
	$row['srv'] 	= trim($stat-&gt;find('a',1)-&gt;href);
	$row['srv_txt'] = trim($stat-&gt;find('a',1)-&gt;plaintext);
	$output[] = $row;

}
echo "&lt;pre&gt;",print_r($output,true),"&lt;/pre&gt;";
exit;

?&gt;</pre>
<p>And that&#8217;s it.</p>
<p>Now take a look at that, and realize how much stuff I&#8217;m not forced to do.</p>
<p>I know this isn&#8217;t some great new invention, loading the source into a DOM object and parsing it, but man, this almost eliminates the need to think about screen scraping entirely.</p>
<p>Enjoy.</p>

<p><a href="http://feedads.googleadservices.com/~a/B-_a2-2hxxeKPVZcwZeB8vza28k/a"><img src="http://feedads.googleadservices.com/~a/B-_a2-2hxxeKPVZcwZeB8vza28k/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/exHmjufJ1_Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/</feedburner:origLink></item>
		<item>
		<title>Search Engine Spam Videos</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/l39SrTeki3A/</link>
		<comments>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 18:33:41 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[protect]]></category>

		<category><![CDATA[seo]]></category>

		<category><![CDATA[spam]]></category>

		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=59</guid>
		<description><![CDATA[Some some tweets come in and I headed on over to IM Broadcast saw some Search Engine Spam videos come up.
I thought they were pretty interesting to watch, and it was nice to hear from MSN, Google, and Yahoo. It does make me wonder if black hat SEO really does have a chance?  
Anyways, [...]]]></description>
			<content:encoded><![CDATA[<p>Some some <a title="My Twitter" href="http://www.twitter.com/dschreck" target="_blank">tweets</a> come in and I headed on over to <a title="IM Broadcast" href="http://www.imbroadcast.com" target="_blank">IM Broadcast</a> saw some Search Engine Spam videos come up.</p>
<p>I thought they were pretty interesting to watch, and it was nice to hear from MSN, Google, and Yahoo. It does make me wonder if black hat SEO really does have a chance? <img src='http://www.iwilldomybest.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
<p>Anyways, here are the direct links to the vids:</p>
<p><a title="Part One" href="http://www.imbroadcast.com/video/53/Search-Engine-Spam-Part-1-Overview" target="_blank">http://www.imbroadcast.com/video/53/Search-Engine-Spam-Part-1-Overview</a></p>
<p><a title="Part Two" href="http://www.imbroadcast.com/video/55/Search-Engine-Spam-Part-2-On-The-Page-Issues" target="_blank">http://www.imbroadcast.com/video/55/Search-Engine-Spam-Part-2-On-The-Page-Issues</a></p>
<p><a title="Part Three" href="http://www.imbroadcast.com/video/54/Search-Engine-Spam-Part-3-Link-Spam--Paid-Links" target="_blank">http://www.imbroadcast.com/video/54/Search-Engine-Spam-Part-3-Link-Spam&#8211;Paid-Links</a></p>
<p>Hope you all enjoy.</p>

<p><a href="http://feedads.googleadservices.com/~a/t7IstqfeopHI9J1M5gXHHBZUaN0/a"><img src="http://feedads.googleadservices.com/~a/t7IstqfeopHI9J1M5gXHHBZUaN0/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/l39SrTeki3A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/</feedburner:origLink></item>
		<item>
		<title>PHP Reference Card - Failed?</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/R3dw1OXTa7s/</link>
		<comments>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 17:48:49 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[ref card]]></category>

		<category><![CDATA[reference card]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=53</guid>
		<description><![CDATA[While taking a look at my &#8216;Tech Blogs&#8217; tab in NetVibes I saw the headline for a reference card available for PHP. So, I hopped on over to dZone.com, got an account (it&#8217;s free), and downloaded it.
I&#8217;m not really impressed.
I believe the beginner may benefit from this, but there&#8217;s just so many gaping holes in [...]]]></description>
			<content:encoded><![CDATA[<p>While taking a look at my &#8216;Tech Blogs&#8217; tab in <a title="NetVibes" href="http://www.netvibes.com/" target="_blank">NetVibes</a> I saw the headline for a <a title="http://refcardz.dzone.com/refcardz/php?oid=ban00022-15" href="http://refcardz.dzone.com/refcardz/php?oid=ban00022-15" target="_blank">reference card available</a> for PHP. So, I hopped on over to dZone.com, got an account (it&#8217;s free), and downloaded it.</p>
<p>I&#8217;m not really impressed.</p>
<p>I believe the beginner may benefit from this, but there&#8217;s just so many gaping holes in the reference card&#8230; Like what about the GD library? Or perhaps cURL? File handling? XML?</p>
<p>Honestly, how could you call a reference card a PHP Reference Card without the most common uses listed? I think the card may be off to a good start, but please, release a new more complete version soon.</p>
<p>Final Verdict:</p>
<p>While it may be great for beginners, it&#8217;s still lacking for the rest of us. I&#8217;ll pass and keep php.net as my reference card.</p>

<p><a href="http://feedads.googleadservices.com/~a/IIencVkCstzZF8J9mamoumLJOy4/a"><img src="http://feedads.googleadservices.com/~a/IIencVkCstzZF8J9mamoumLJOy4/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/R3dw1OXTa7s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/</feedburner:origLink></item>
		<item>
		<title>Breathalyzer for your Gmail</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/4zlaqUTnn1k/</link>
		<comments>http://www.iwilldomybest.com/2008/10/breathalyzer-for-your-gmail/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 22:47:38 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<category><![CDATA[Personal Life]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[gmail]]></category>

		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=45</guid>
		<description><![CDATA[Personally, I think this is a pretty neat little gizmo. Basically, in a blog post at: http://gmailblog.blogspot.com/2008/10/new-in-labs-stop-sending-mail-you-later.html  by Jon Perlow, Gmail engineer, released a little configurable labs tool that challenges you sending off an email.
All you have to do is answer a few simple math problems, and boom, off it goes. I think the [...]]]></description>
			<content:encoded><![CDATA[<p>Personally, I think this is a pretty neat little gizmo. Basically, in a blog post at: <a title="http://gmailblog.blogspot.com/2008/10/new-in-labs-stop-sending-mail-you-later.html" href="http://gmailblog.blogspot.com/2008/10/new-in-labs-stop-sending-mail-you-later.html" target="_blank">http://gmailblog.blogspot.com/2008/10/new-in-labs-stop-sending-mail-you-later.html</a> <span class="byline-author"> by Jon Perlow, Gmail engineer, released a little configurable labs tool that challenges you sending off an email.</span></p>
<p>All you have to do is answer a few simple math problems, and boom, off it goes. I think the idea here is it gives you a second chance to reconsider your email. And, if you&#8217;re too drunk to think of an answer, perhaps you should wait till the next day to send it.</p>
<p>I think it&#8217;s neat, and of course, you can turn it on and off, so if anyone is complaining about that, well, they&#8217;re just silly.</p>

<p><a href="http://feedads.googleadservices.com/~a/-FuIomTTmoRma46BSbuvD3wCDGo/a"><img src="http://feedads.googleadservices.com/~a/-FuIomTTmoRma46BSbuvD3wCDGo/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/4zlaqUTnn1k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/breathalyzer-for-your-gmail/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/breathalyzer-for-your-gmail/</feedburner:origLink></item>
		<item>
		<title>New Version, New Theme</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/2raxQukFYkM/</link>
		<comments>http://www.iwilldomybest.com/2008/10/new-version-new-theme/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 22:32:14 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=26</guid>
		<description><![CDATA[I went ahead and updated wordpress, so we&#8217;ll see if this version stays stable.
Also, changed themes, until I finish with my own. Hopefully this will be the last time before I settle on my own.

]]></description>
			<content:encoded><![CDATA[<p>I went ahead and updated wordpress, so we&#8217;ll see if this version stays stable.</p>
<p>Also, changed themes, until I finish with my own. Hopefully this will be the last time before I settle on my own.</p>
<p></p>

<p><a href="http://feedads.googleadservices.com/~a/7x3cBl4BEe3vXJd0LHIoBH8ZBYw/a"><img src="http://feedads.googleadservices.com/~a/7x3cBl4BEe3vXJd0LHIoBH8ZBYw/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/2raxQukFYkM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/new-version-new-theme/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/new-version-new-theme/</feedburner:origLink></item>
		<item>
		<title>PHP &amp; MySQL Tip #3</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/71YwQnYtGhY/</link>
		<comments>http://www.iwilldomybest.com/2008/08/php-mysql-tip-3/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 22:52:05 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Development]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[design patterns]]></category>

		<category><![CDATA[eav]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/2008/08/25/php-mysql-tip-3/</guid>
		<description><![CDATA[PHP &#38; MySQL Tip #3
I want to share with some of you an easy way to set up your database design in a very flexiable and reliable EAV like model.

EAV stands for Entity Attribute Value, which is a common design for complex database structures that require many different Entities using many different attributes with, again, [...]]]></description>
			<content:encoded><![CDATA[<p>PHP &amp; MySQL Tip #3</p>
<p>I want to share with some of you an easy way to set up your database design in a very flexiable and reliable EAV like model.</p>
<p><span id="more-20"></span></p>
<p><a title="http://en.wikipedia.org/wiki/Entity-attribute-value_model" href="http://en.wikipedia.org/wiki/Entity-attribute-value_model" target="_blank">EAV</a> stands for Entity Attribute Value, which is a common design for complex database structures that require many different Entities using many different attributes with, again, many different values. It&#8217;s very common to find this set up in medical offices or records.</p>
<p>Let&#8217;s go ahead and assume a situation, and we&#8217;ll work through it.</p>
<p>Let&#8217;s say you&#8217;re accepting a feed of some sort, and you need to save the items being fed to you into a database. The problem here, is that the content length of these items, attributes, and values varies.</p>
<p>So let&#8217;s consider the following:</p>
<pre>Item 'Node1' -&gt;
	Attribute 'Main' -&gt;
		Value 1
		Value 2
		Value 3
		Value 4
Item 'Node2' -&gt;
	Attribute 'Main' -&gt;
		Value 1
		Value 2
		Value 3
		Value 4
	Attribute 'Other' -&gt;
		Value 1
		Value 2

Item 'Node3' -&gt;
	Attribute 'Main' -&gt;
		Value 1
		Value 2
		Value 3
		Value 4
		Value 5
		Value 6
		Value 7
		Value 8</pre>
<p>Now this is a very cheap and generic example of a data structure. But we&#8217;ll work with it for now.</p>
<p>So let&#8217;s go ahead and draw some conclusions.</p>
<p>The Item list will come in with a name, and have Attributes. These attributes will have values. But the number of attributes and the number of values varies.</p>
<p>So with that in mind, we shall come up with some SQL to create some times. For this example we&#8217;re going to need three tables: items, item_attributes, and attribute_values.</p>
<p>So here we go:</p>
<p><code><br />
-- first our items table:<br />
CREATE TABLE `items` (<br />
`id` int(11) NOT NULL auto_increment,<br />
`item_name` varchar(50) default NULL,<br />
PRIMARY KEY  (`id`)<br />
);<br />
-- now our item attributes<br />
CREATE TABLE  `item_attributes` (<br />
`id` int(11) NOT NULL auto_increment,<br />
`item_id` int(11) NOT NULL default '0',<br />
`attribute_name` varchar(50) default NULL,<br />
PRIMARY KEY  (`id`),<br />
KEY `item_id_attribute_name` (`item_id`,`attribute_name`)<br />
);<br />
-- now finally our attribute values<br />
CREATE TABLE  `attribute_values` (<br />
`attribute_id` int(11) NOT NULL default '0',<br />
`attribute_value` varchar(100) default NULL,<br />
UNIQUE KEY `attribute_id` (`attribute_id`,`attribute_value`)<br />
);<br />
</code></p>
<p>Now that we have our layout, let&#8217;s take a look at how this is going to work:</p>
<p>Let&#8217;s assume the following PHP array is a reprentation of our data&#8230;</p>
<pre>// start up our array
$data = array();
//
// Now, let's just load it with some test data
$data['item_1'] = array();
$data['item_1']['attribute_1'] = array();
$data['item_1']['attribute_1'][] = 'value1';
$data['item_1']['attribute_1'][] = 'value2';
$data['item_1']['attribute_1'][] = 'value3';
$data['item_1']['attribute_1'][] = 'value4';
// that's good for now.
/**
* Now let's insert this int our new schema
*
* Please note, for example sake, I will not be double checking queries
* but you SHOULD check each query for an error.
**/
foreach($data as $item_name =&gt; $attributes)
{
	$sql = "INSERT INTO items (id, item_name) VALUES (NULL, '{$item_name}');";
	mysql_query($sql);
	$item_id = mysql_insert_id();
	// now let's loop through our attributes
	foreach($attributes as $attribute =&gt; $values)
	{
		// this is now our insert into the attributes...
		$sql = "INSERT INTO item_attributes (id, item_id, attribute_name) VALUES (NULL, {$item_id}, '{$attribute}');";
		mysql_query($sql);
		$attribute_id = mysql_insert_id();
		// now let's loop through the attribute values
		foreach($values as $value)
		{
			$sql = "INSERT INTO attribute_values (attribute_id, attribute_value) VALUES ({$attribute_id}, '{$value}');";
			mysql_query($sql);
		}
	}
}
?&gt;</pre>
<p>And there you have it - that&#8217;s now how we can get our data into our database in a flexiable manner, without having to rely<br />
on an &#8216;excel&#8217; like database.</p>
<p>To get it out, we&#8217;ll simply use some joins&#8230;</p>
<p><code><br />
$sql =<br />
"SELECT<br />
items.item_name,<br />
ia.attribute_name,<br />
av.attribute_value<br />
FROM<br />
attribute_values AS av<br />
JOIN item_attributes AS ia<br />
ON (ia.id = av.attribute_id)<br />
JOIN items AS items<br />
ON (items.id = ia.item_id);<br />
";<br />
</code></p>
<p>You could also use a concat_ws to make a comma seperated list, but now that you have it in your database, you can do anything you want with it <img src='http://www.iwilldomybest.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.googleadservices.com/~a/y9vvhYrykPVDQqDu9zbxvZMaMcQ/a"><img src="http://feedads.googleadservices.com/~a/y9vvhYrykPVDQqDu9zbxvZMaMcQ/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/71YwQnYtGhY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/08/php-mysql-tip-3/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/08/php-mysql-tip-3/</feedburner:origLink></item>
		<item>
		<title>Work that DOM</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/2zG5P5t7erc/</link>
		<comments>http://www.iwilldomybest.com/2008/08/work-that-dom/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 19:59:25 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/2008/08/18/work-that-dom/</guid>
		<description><![CDATA[Just real quick, this came up in #javascript the other day. Working with the DOM, appending new elements.

Here&#8217;s the basic idea.
You have your DOM, and with JavaScript, there are ways to manipulate nodes. Including adding new ones.  When you want to add new elements to your DOM, you have to think about this in [...]]]></description>
			<content:encoded><![CDATA[<p>Just real quick, this came up in <a title="#JavaScript on IRC.GAMESURGE.NET" href="irc://irc.gamesurge.net/javascript" target="_blank">#javascript</a> the other day. Working with the DOM, appending new elements.</p>
<p><span id="more-19"></span></p>
<p>Here&#8217;s the basic idea.</p>
<p>You have your <a title="http://en.wikipedia.org/wiki/Document_Object_Model" href="http://en.wikipedia.org/wiki/Document_Object_Model" target="_blank">DOM</a>, and with JavaScript, there are ways to manipulate nodes. Including adding new ones.  When you want to add new elements to your DOM, you have to think about this in a few different steps.</p>
<p><strong>First step, where am I placing this?</strong><br />
The reason for this is because you have to select an element to append your new element to. You can append it to the body, the head, or other element. So we start this off with the assumption that we have a <strong>div</strong> with the id of <em>inner_content</em>.</p>
<p>So we start out our JavaScript with:<br />
<code><br />
var main_div = document.getElementById('inner_content');<br />
</code></p>
<p><strong>Second step, what are we going to create?</strong><br />
Let&#8217;s say we want to add another div with some text inside of it. So, we now create the new div, and append it to our main_div variable.<br />
<code><br />
...<br />
var new_div = document.createElement('div');<br />
...<br />
</code></p>
<p>This div needs some attributes! So let&#8217;s hop into that, the above snippet turns into:<br />
<code><br />
...<br />
var new_div = document.createElement('div');<br />
new_div.setAttribute('id','sub_div');<br />
new_div.setAttribute('class','mySubDivCssClass');<br />
new_div.setAttribute('onclick','javaScriptFunction()');<br />
...<br />
</code></p>
<p>Now we need to actually attach this item to our old div.</p>
<p>To do that we simply tell our main_div to append a child:<br />
<code><br />
...<br />
main_div.appendChild( new_div );<br />
...<br />
</code></p>
<p>Now, say we want to add a text node&#8230; now that gets its own special tool.</p>
<p><code><br />
var new_text = document.createTextNode('My New Text');<br />
</code></p>
<p>And now, just like before, we need to attach that to an item it belongs to.</p>
<p><code><br />
new_div.appendChild( new_text );<br />
</code></p>
<p>Now, we end up with our code snippet looking something like this:</p>
<p><code><br />
var main_div = document.getElementById('inner_content');<br />
var new_div = document.createElement('div');<br />
var new_text = document.createTextNode('My New Text');<br />
// now set up our attributes<br />
new_div.setAttribute('id','sub_div');<br />
new_div.setAttribute('class','mySubDivCssClass');<br />
new_div.setAttribute('onclick','javaScriptFunction()');<br />
// now append the text to the new div<br />
new_div.appendChild( new_text );<br />
// now append our new div to our main div<br />
main_div.appendChild( new_div );<br />
// done.<br />
</code></p>
<p>And that&#8217;s about as easy as it gets.</p>
<p>Hope this helps someone understand the order that is required when appending new children to the node list.</p>
<p><strong>For more information:</strong></p>
<p><a title="http://www.w3schools.com/htmldom/" href="http://www.w3schools.com/htmldom/" target="_blank">http://www.w3schools.com/htmldom/</a><br />
<a title="http://www.w3.org/TR/DOM-Level-2-HTML/" href="http://www.w3.org/TR/DOM-Level-2-HTML/" target="_blank">http://www.w3.org/TR/DOM-Level-2-HTML/</a><br />
<a title="http://developer.mozilla.org/en/docs/Using_the_W3C_DOM_Level_1_Core" href="http://developer.mozilla.org/en/docs/Using_the_W3C_DOM_Level_1_Core" target="_blank">http://developer.mozilla.org/en/docs/Using_the_W3C_DOM_Level_1_Core</a></p>

<p><a href="http://feedads.googleadservices.com/~a/GOIC17Q1urWNE6wMlQh9w4v4bzA/a"><img src="http://feedads.googleadservices.com/~a/GOIC17Q1urWNE6wMlQh9w4v4bzA/i" border="0" ismap="true"></img></a></p><img src="http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~4/2zG5P5t7erc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/08/work-that-dom/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/08/work-that-dom/</feedburner:origLink></item>
	</channel>
</rss>
