<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brendan &#38; Tiffany Sullivan &#187; Programming</title>
	<atom:link href="http://www.sullivanrealm.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sullivanrealm.net</link>
	<description>The most interesting things on the web! (hah!)</description>
	<lastBuildDate>Wed, 01 Sep 2010 12:00:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hawkins Computer Services has an office!</title>
		<link>http://www.sullivanrealm.net/2010/02/28/hawkins-computer-services-has-an-office/</link>
		<comments>http://www.sullivanrealm.net/2010/02/28/hawkins-computer-services-has-an-office/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 02:28:23 +0000</pubDate>
		<dc:creator>brendan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[hcs]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.sullivanrealm.net/?p=696</guid>
		<description><![CDATA[Well after almost 2 years of working from home, we at Hawkins Computer Services finally have a real office space! About two weeks ago, Emmett went on a hardcore search for a good office space in the area that would suffice for the 3 of us. In the span of a week he signed the [...]]]></description>
			<content:encoded><![CDATA[<p>Well after almost 2 years of working from home, we at Hawkins Computer Services finally have a real <a title="Google Maps" href="http://maps.google.com/maps?source=ig&amp;hl=en&amp;ie=UTF8&amp;q=406+ellis+ave,+maryville,+tn&amp;fb=1&amp;gl=us&amp;hnear=&amp;cid=0,0,1455139539415518549&amp;ei=mhGLS62iEJG0tgfmosXyBw&amp;ved=0CAcQnwIwAA&amp;hq=406+ellis+ave,+maryville,+tn&amp;ll=35.756427,-83.966838&amp;spn=0,359.997589&amp;t=h&amp;z=19&amp;layer=c&amp;cbll=35.756375,-83.96676&amp;panoid=XVBUn63KtVWzWwB_bKTiIw&amp;cbp=12,33.38,,0,11.17" target="_blank">office space</a>! About two weeks ago, Emmett went on a hardcore search for a good office space in the area that would suffice for the 3 of us. In the span of a week he signed the lease, got internet and phone installed, bought desks, computer equipment, etc, and generally got the place setup.</p>
<div id="attachment_713" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1427-Modified.jpg"><img class="size-medium wp-image-713" title="DSCN1427 (Modified)" src="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1427-Modified-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Entrance to Office</p></div>
<p>The couple of days before we officially moved in we brought equipment over and Jennifer, Ray, Emmett, and I got the new desks built, painted the walls, put up decor, ran networking, etc. Thursday was our first official day over there and we&#8217;re getting settled in. I can&#8217;t wait for our first full week over there&#8230; should help us all be more productive and improve our communication with each other and clients.</p>
<div id="attachment_714" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1428-Modified.jpg"><img class="size-medium wp-image-714" title="DSCN1428 (Modified)" src="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1428-Modified-400x300.jpg" alt="Left: My desk ~ Right: Ray's Desk" width="400" height="300" /></a><p class="wp-caption-text">Left: My desk ~ Right: Ray&#39;s Desk</p></div>
<p>Ray and I occupy the front room of the office. We&#8217;ve got our desks facing each other and have all the power/networking stuff between them. Not that pretty, but a reasonable solution for now. I think we&#8217;re going to put a printer against the wall under the &#8220;square&#8221; on the wall.</p>
<div id="attachment_719" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1433.jpg"><img class="size-medium wp-image-719" title="DSCN1433" src="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1433-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">My desk, desktop, laptop, etc</p></div>
<p>I have created my little corner. Emmett bought chairs and desks and monitors. I brought one of my spare desktops over to use for the time being and I&#8217;ve been bringing my laptop for&#8230;. well I don&#8217;t really know what&#8230; I just find it&#8217;s useful to have two computers sometimes <img src='http://www.sullivanrealm.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="attachment_718" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1432.jpg"><img class="size-medium wp-image-718" title="DSCN1432" src="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1432-400x300.jpg" alt="Kermit's Office" width="400" height="300" /></a><p class="wp-caption-text">Kermit&#39;s Office</p></div>
<p>Emmett got the back office&#8230;there are a couple of chairs for clients on the opposite wall.</p>
<div id="attachment_720" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1434.jpg"><img class="size-medium wp-image-720" title="DSCN1434" src="http://www.sullivanrealm.net/wp-content/uploads/2010/02/DSCN1434-400x300.jpg" alt="" width="400" height="300" /></a><p class="wp-caption-text">Contents of my top drawer</p></div>
<p>This is Tiffany&#8217;s favorite part. The contents of my desk drawer. CDs, network tester, tools, and a stash of taco sauce in case I get lunch one day and want some taco sauce. Not sure why that&#8217;s so hilarious, but she insisted on taking a picture.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sullivanrealm.net/2010/02/28/hawkins-computer-services-has-an-office/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Latest work &#8211; Internal Kiosk Site</title>
		<link>http://www.sullivanrealm.net/2010/01/27/latest-work-internal-kiosk-site/</link>
		<comments>http://www.sullivanrealm.net/2010/01/27/latest-work-internal-kiosk-site/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 03:48:26 +0000</pubDate>
		<dc:creator>brendan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[kiosk]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.sullivanrealm.net/?p=641</guid>
		<description><![CDATA[I finally have something really cool to show from my job. We have a client who wanted a &#8220;Kiosk&#8221; in their rental office that guests could browse through the various units they have available. It did not need to do anything that different than our normal web work&#8230;.choose arrival date, number of nights, number of [...]]]></description>
			<content:encoded><![CDATA[<p>I finally have something really cool to show from my job. We have a client who wanted a &#8220;Kiosk&#8221; in their rental office that guests could browse through the various units they have available. It did not need to do anything that different than our normal web work&#8230;.choose arrival date, number of nights, number of guests, etc. The challenge was how to do it all with JUST a touch screen for input. The &#8220;kiosk&#8221; was going to be one of the new &#8220;all-in-one&#8221; MSI Wind Top PC&#8217;s with a 20&#8243; touch screen.</p>
<div id="attachment_659" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/index.jpg"><img class="size-medium wp-image-659" title="index" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/index-400x249.jpg" alt="Index Page" width="400" height="249" /></a><p class="wp-caption-text">Index Page.... simple, no nonsense. Also -- Boring</p></div>
<p>I had <em>some</em> idea of what was going on since I built a small .mobi site for this company last year geared toward the iPhone/iPod Touch. It turned out OK, but was nothing I really felt stood out. It works, but I honestly don&#8217;t think it gets much attention. I&#8217;d like to revisit it sometime and make some improvements with what I&#8217;ve learned on this project.</p>
<div id="attachment_656" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/date-select.jpg"><img class="size-medium wp-image-656" title="date-select" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/date-select-400x250.jpg" alt="" width="400" height="250" /></a><p class="wp-caption-text">Date and Nights Selection</p></div>
<p>The site will not be available outside of this office, but I&#8217;ve got some screenshots AND A VIDEO showing off the functionality. I&#8217;m not much of a designer, so it&#8217;s not as pretty as it could be probably, but it works I think. I&#8217;ll post a couple of the fun jQuery stuff I found/did as well. I think the most instructional and entertaining part was modifying the jQuery quicksearch plugin from <a href="http://rikrikrik.com/jquery/quicksearch/" target="_blank">www.rikrikrik.com</a> to be able to use an on-screen keyboard.</p>
<p>And somehow I don&#8217;t have a screenshot of that&#8230;will update later <img src='http://www.sullivanrealm.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Rather than creating a separate keyboard and try to tie it into the event handling for quicksearch, I ended up extending the plugin, adding new functionality through the options passed during the .quicksearch() call so the keyboard was fully integrated. It took some trial and error, and it likely could be done &#8220;better&#8221;, but it works, and functions great.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'table#cabin_names tbody tr'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">quicksearch</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				position<span style="color: #339933;">:</span><span style="color: #3366CC;">'after'</span><span style="color: #339933;">,</span>
				attached<span style="color: #339933;">:</span><span style="color: #3366CC;">'#uber_wrap'</span><span style="color: #339933;">,</span>
				labelText<span style="color: #339933;">:</span><span style="color: #3366CC;">''</span><span style="color: #339933;">,</span>
				inputClass<span style="color: #339933;">:</span><span style="color: #3366CC;">'sel wide'</span><span style="color: #339933;">,</span>
				watchElement<span style="color: #339933;">:</span><span style="color: #3366CC;">'li.alpha_btns'</span><span style="color: #339933;">,</span>
				keyboard<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
				keyboardId<span style="color: #339933;">:</span> <span style="color: #3366CC;">'alpha_btns'</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The &#8216;watchElement&#8217; option is the elements that should trigger the qs() function in quicksearch. &#8216;keyboard&#8217; defaults to false, but when set to <strong>true</strong>, it renders the html to insert the keyboard and bind the events to do the proper stuff. &#8216;keyboardId&#8217; just lets you define the element Id so you can style at will. This extension of the plugin likely has no real use beyond sites designed for touch screens, but it was still educational, and was an interesting introduction to plugins in jQuery. I&#8217;ve never written my own, but if I find some functionality I need in the future, maybe I can break into that field too.</p>
<div id="attachment_658" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/guest-select.jpg"><img class="size-medium wp-image-658" title="guest-select" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/guest-select-400x250.jpg" alt="" width="400" height="250" /></a><p class="wp-caption-text"># of Guests</p></div>
<p>Anyhow, there&#8217;s not much else to say. This site was designed specifically for this screen, specifically to run in Firefox, specifically in Fullscreen mode. If I had more time I think it could be made to be a bit more flexible, but I suck at CSS, and I just didn&#8217;t know how to make a few things flow fluidly on different sized screens. Enjoy!</p>
<p><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/kiosk_demo.wmv">kiosk_demo</a></p>
<div id="attachment_655" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/cabin-list.jpg"><img class="size-medium wp-image-655" title="cabin-list" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/cabin-list-400x251.jpg" alt="" width="400" height="251" /></a><p class="wp-caption-text">List of cabins available for selected dates and # of guests</p></div>
<p>One of the other really fun things to write/integrate was the scrolling buttons. I realized after the initial design that having regular scrollbars just wouldn&#8217;t be usable with a touch screen interface. Theoretically I could have altered the Firefox userContent.css to enlarge the scroll bars to the point they <em>would</em> have been usable, but that just didn&#8217;t feel right. Once again, though, jQuery plugins to the rescue! I found a nice little scrolling plugin that allowed me to bind relative scroll positions <strong>with easing</strong> to click events on the fixed-position nav-box on the right side. Not sure I&#8217;m thrilled with how it looks right now, but at least it&#8217;s functionally complete. Can always tweak it down the road.</p>
<div id="attachment_657" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/filters.jpg"><img class="size-medium wp-image-657" title="filters" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/filters-400x250.jpg" alt="" width="400" height="250" /></a><p class="wp-caption-text">Fun screen to write. &quot;Buttons&quot; are actually labels for hidden checkboxes. jQuery styling changes make it look fancy</p></div>
<div id="attachment_654" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sullivanrealm.net/wp-content/uploads/2010/01/cabin.jpg"><img class="size-medium wp-image-654" title="cabin" src="http://www.sullivanrealm.net/wp-content/uploads/2010/01/cabin-400x252.jpg" alt="" width="400" height="252" /></a><p class="wp-caption-text">Individual cabin page...small photos are clickable to rotate through pictures</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sullivanrealm.net/2010/01/27/latest-work-internal-kiosk-site/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.sullivanrealm.net/wp-content/uploads/2010/01/kiosk_demo.wmv" length="6130077" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>couple of fun and useful jQuery Plugins</title>
		<link>http://www.sullivanrealm.net/2009/11/12/couple-of-fun-and-useful-jquery-plugins/</link>
		<comments>http://www.sullivanrealm.net/2009/11/12/couple-of-fun-and-useful-jquery-plugins/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 05:00:57 +0000</pubDate>
		<dc:creator>brendan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[ajaxForm]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.sullivanrealm.net/?p=117</guid>
		<description><![CDATA[I am far from an accomplished web developer, but jQuery is one tool that helps out immensely in writing javascript that &#8220;just works&#8221;. As many of you are aware, browser differences create all sorts of havoc when trying to write code that navigates the DOM. And writing code from scratch to validate forms is a [...]]]></description>
			<content:encoded><![CDATA[<p>I am far from an accomplished web developer, but jQuery is one tool that helps out immensely in writing javascript that &#8220;just works&#8221;. As many of you are aware, browser differences create all sorts of havoc when trying to write code that navigates the DOM. And writing code from scratch to validate forms is a serious pain in the butt. So here are a few <a href="http://jquery.com">jQuery</a> plugins that might make your life a little easier in that regard.</p>
<p>First off, there is the the combined magic of the <a href="http://malsup.com/jquery/form/">jquery Form plugin from malsup.com</a> which creates a nice AJAX-submitted form with one quick line of code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxForm</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Optionally, you can pass the .ajaxForm() function any <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options">options</a> that you would normally pass to a regular jQuery .ajax() method like so&#8230;.</p>
<p>Now that&#8217;s fun, but it can be extended just a LITTLE bit more with the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jquery validate plugin</a>. Here we can define some simple rules in JSON format and the validation plugin will automatically display customizable messages for any errors that are found before submitting the form. The validation function takes the option <em>submitHandler </em>to create the ajaxSubmit event from the Form plugin above.</p>
<p>Here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactus_form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	submitHandler<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>form<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span>form<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxSubmit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			error<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	rules<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;required&quot;</span><span style="color: #339933;">,</span>
		email<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			required<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			email<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		message<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;required&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	messages<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Name is required&quot;</span><span style="color: #339933;">,</span>
		email<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			required<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Email is required&quot;</span><span style="color: #339933;">,</span>
			email<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Email is in an invalid format&quot;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		message<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Some message to the staff is required&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	errorLabelContainer<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#ajaxmsg&quot;</span><span style="color: #339933;">,</span>
	wrapper<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;li&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Obviously you need to validate the data in whatever script you are handling on the server side, but the jQuery error messages are a great way to improve your forms usability and they can be styled to be attractive and make any input errors very clear to your users.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sullivanrealm.net/2009/11/12/couple-of-fun-and-useful-jquery-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Evils of PHP magic_quotes_gpc</title>
		<link>http://www.sullivanrealm.net/2009/10/17/the-evils-of-php-magic_quotes_gpc/</link>
		<comments>http://www.sullivanrealm.net/2009/10/17/the-evils-of-php-magic_quotes_gpc/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 14:13:35 +0000</pubDate>
		<dc:creator>brendan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Websites]]></category>

		<guid isPermaLink="false">http://www.sullivanrealm.net/?p=125</guid>
		<description><![CDATA[I&#8217;m honestly surprised this hasn&#8217;t bit me before now. I was working on some OLD code that didn&#8217;t have much of any escaping built into it. Ok, I take that back. It had /no/ validation methods whatsoever. So I&#8217;m rewriting a good chunk of it so that doing things like entering a person&#8217;s name that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m honestly surprised this hasn&#8217;t bit me before now. I was working on some OLD code that didn&#8217;t have much of any escaping built into it. Ok, I take that back. It had /no/ validation methods whatsoever. So I&#8217;m rewriting a good chunk of it so that doing things like entering a person&#8217;s name that happens to have an apostrophe in it actually works and doesn&#8217;t break the SQL query.</p>
<p>So, you take a query in php with no validation and add mysql_real_escape_string() to the values you are inserting/updating right?</p>
<p>Well, it turns out it&#8217;s not /quite/ that easy <em>if</em> the lovely php magic_quotes_gpc is on. The insert or update will succeed (albeit with nasty escaping characters in your data). But now go try and select row (imagining your searching for a name) using a query such as :</p>
<p>&#8220;SELECT * FROM guest WHERE name LIKE &#8216;%&#8221;.mysql_real_escape_string($name).&#8221;%&#8217;&#8221;;</p>
<p>MySQL at least will not find your data. If the name field you were searching for contained &#8220;test\&#8217;s name&#8221; and you searched for &#8220;test&#8217;s&#8221;, the escape function above would insert the backslash and if you viewed your MySQL log, it would appear that MySQL had gone off the deep end. You print your table and clearly see &#8220;test\&#8217;s name&#8221;, but your query (truncated to the relevant portion) &#8221; name LIKE &#8216;%test\&#8217;s%&#8217;&#8221; returns zero results.</p>
<p>My first thought was to &#8220;escape the escape character&#8221;. So like a dumbass, I try this mess: addslashes(mysql_real_escape_string($name)). I figured there&#8217;s no way that they would make you jump through this many hoops to deal with escaped data, and in that regard at least I was right. It&#8217;s much, MUCH easier than all that. (For the record, not even the previous monstrosity worked. Playing with queries manually in MySQL&#8217;s CLI, i found if you ran a search &#8221; LIKE &#8216;%test\\\\&#8217;s%&#8217; &#8221; it would FINALLY find it. But that looks terrible, and there&#8217;s no way that such a commonly used language would get that way if it required ugly unreadable code like that.</p>
<p>So, the solution I found after plenty of reading:</p>
<p>#1) If you have full access to your server (dedicated, VPS, your home test server), in /etc/php5/apache2/php.ini (for Ubuntu Server at least) change the line:</p>
<p>magic_quotes_gpc = On</p>
<p>to</p>
<p>magic_quotes_gpc = Off</p>
<p>Be sure to then restart your apache service using</p>
<p>sudo /etc/init.d/apache2 restart</p>
<p>#2) if you do not have root access to your server (Shared hosting, etc), you can use a rule in your webroot&#8217;s .htaccess. Add the line:</p>
<p>php_flag magic_quotes_gpc off</p>
<p>preferably in the top of the file so it&#8217;s nice and easy to find. I believe this will only work on linux apache servers. Windows does not support .htaccess for anything but password authentication I believe. But you should be running your apache server on linux anyhow <img src='http://www.sullivanrealm.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, this was a really newb mistake, but I learned my lesson and figured maybe this could help someone else out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sullivanrealm.net/2009/10/17/the-evils-of-php-magic_quotes_gpc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
