<?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>One man's voice &#187; Geek Stuff</title>
	<atom:link href="http://www.robert-gonzalez.com/category/geek-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robert-gonzalez.com</link>
	<description>Thoughts, rants and commentary from a husband, father of five and professional web geek</description>
	<lastBuildDate>Tue, 08 Jun 2010 23:22:36 +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>Uninstalling Windows Live Messenger on Windows XP</title>
		<link>http://www.robert-gonzalez.com/2009/11/01/uninstalling-windows-live-messenger-on-windows-xp/</link>
		<comments>http://www.robert-gonzalez.com/2009/11/01/uninstalling-windows-live-messenger-on-windows-xp/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 13:17:10 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Personal Messages]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Instant Messengers]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2393</guid>
		<description><![CDATA[The other day, while doing some routine cleanup on my machine at work, I ran into a bit of a snag when trying to uninstall Windows Live Messenger. Unlike most common software packages that include an uninstall utility, Windows Live Messenger, in a move typical of the Redmond Beast known commonly as Microsoft, does not.
After [...]]]></description>
			<content:encoded><![CDATA[<p>The other day, while doing some routine cleanup on my machine at work, I ran into a bit of a snag when trying to uninstall Windows Live Messenger. Unlike most common software packages that include an uninstall utility, Windows Live Messenger, in a move typical of the Redmond Beast known commonly as Microsoft, does not.</p>
<p>After searching for a tutorial on how to remove this piece of crap software from my machine I decided to just try something.</p>
<p><strong>Quick sidebar: If you are ever at the point of not trying something yourself in favor of asking someone how to do what you need to do, slap yourself three times, repeat "I am not a n00b" to yourself three times, send me $10 then try something. Seriously, just try something.</strong></p>
<p>What I did was launch my Add/Remove Programs utility from the control panel (<strong>Start</strong> -> <strong>Control Panel</strong> -> <strong>Add/Remove Programs</strong>) then, after much searching, cursing and an increased disposition to hate Microsoft, finding, I decided to click on the <strong>Windows Live Essentials</strong> package and click the <strong>Change/Remove</strong> button.</p>
<p>From there I was presented a dialog box that gave me two options: <strong>Uninstall</strong> and <strong>Repair</strong>. I selected <strong>Uninstall</strong> and was then taken to a menu of currently installed Windows Live software. That list, for me, included one application: Messenger. I checked the box next to messenger and started the uninstall process (which I cannot show you because I was so excited to actually get this off my computer that I forgot to take screenshots... and no, I am not reinstalling it just so I can uninstall it again to get screenshots).</p>
<p>Anyway, after a few minutes of working and thinking and more working, Windows reported to me that the application had been successfully uninstalled. Which is way better than I can say for the instructions I found at these two links:
<ul>
<li><a href="http://www.iaskd.com/how-to-uninstall-windows-live-messenger.html">http://www.iaskd.com/how-to-uninstall-windows-live-messenger.html</a></li>
<li><a href="http://www.technoxx.com/uninstall-windows-live-messenger.html">http://www.technoxx.com/uninstall-windows-live-messenger.html</a></li>
</ul>
<p>So if you are tired of having Messenger on your system this is the fastest and most efficient way of getting it off of there. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/11/01/uninstalling-windows-live-messenger-on-windows-xp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>An homage to Geocities</title>
		<link>http://www.robert-gonzalez.com/2009/10/26/an-homage-to-geocities/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/26/an-homage-to-geocities/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 01:08:10 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Cool Finds]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Personal Messages]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Web Sites]]></category>
		<category><![CDATA[Awesome websites]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[Tributes]]></category>
		<category><![CDATA[XKCD]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2370</guid>
		<description><![CDATA[All I can say is thank God Geocities is shutting down today. I wouldn't have known that save for a link sent to me by my coworker. The link was to xkcd.com, one our favorite sites, which today featured a tribute to Geocities websites of old.
In case you missed it, here is the XKCD homepage [...]]]></description>
			<content:encoded><![CDATA[<p>All I can say is thank God Geocities is shutting down today. I wouldn't have known that save for a link sent to me by my coworker. The link was to <a href="http://xkcd.com" title="I wonder if I link to the xkcd website *and* say it is one of *our* favorite sites that I will get some link reciprocation love?">xkcd.com, one our favorite sites</a>, which today featured a tribute to Geocities websites of old.</p>
<p>In case you missed it, here is the XKCD homepage today:</p>
<p class="aligncenter"><a href="http://www.robert-gonzalez.com/wp-content/uploads/2009/10/xkcd-geocities-003.png"><img src="http://www.robert-gonzalez.com/wp-content/uploads/2009/10/xkcd-geocities-003-thumb.png" alt="XKCD homage to Geocities thumbnail" title="&lt;BR&gt;&lt;BR&gt;&lt;BRB&gt;... Best. Markup. Evar." width="550" height="699" class="size-full wp-image-2372" /></a></p>
<p>Anyone else as glad as me that most of those websites (*cough* MySpace *cough*) are now off the internet?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/26/an-homage-to-geocities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recovering your GoDaddy.com hosting password</title>
		<link>http://www.robert-gonzalez.com/2009/10/24/recovering-your-godaddy-com-hosting-password/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/24/recovering-your-godaddy-com-hosting-password/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 22:04:18 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[GoDaddy]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Password Resetting]]></category>
		<category><![CDATA[Tech Support]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2354</guid>
		<description><![CDATA[Today my daughter asked me to install new themes on her blog for her. Normally this would not be a big issue. However, the last time I did any work on her blog was in 2005, when I set it up. And of course, this was like three computers ago, meaning I did not have [...]]]></description>
			<content:encoded><![CDATA[<p>Today my daughter asked me to install new themes on <a title="Have you heard what Sarah said?" href="http://sarahsaid.com">her blog</a> for her. Normally this would not be a big issue. However, the last time I did any work on her blog was in 2005, when I set it up. And of course, this was like three computers ago, meaning I did not have her FTP password any longer.</p>
<p>So after trying all the usual passwords I would have used, then trying some passwords that made sense (knowing the way my brain operates) I decided to just reset the FTP password on her account since there was no noticeable way to recover the password in the GoDaddy hosting control panel. It wasn't until almost 45 minutes later that I found out this was not necessary.</p>
<p><strong>Slight digression:</strong> I found it somewhat odd that it would take GoDaddy between 20 and 30 minutes to change an FTP password. Really, this should take all of one minute at the most, and that is if you type really slow. Still, I was patient for a time before calling GoDaddy tech support and finding out the GoDaddy is rolling out a system upgrade today that will effectively make my password change request take five hours instead of 30 minutes. #godaddy #fail</p>
<p>However, while on the phone with GoDaddy tech support I was taught how to recover your password in the event I ever forget this one. <strong>Please note: I will never, ever, forget my FTP passwords on GoDaddy ever again. Ever.</strong></p>
<p><strong><span style="text-decoration: underline;">Recovering your hosting password on GoDaddy</span></strong><br />
<span style="font-size: 7pt; font-weight: bold;">Note: The following steps assume you have access to your GoDaddy control panel. That means you should be able to log into your GoDaddy account and get to your list of hosting accounts.</span></p>
<ol>
<li>Log into your GoDaddy account</li>
<li>Get to your hosting accounts:
<ul>
<li>Either click on <strong>Hosting</strong> under the <strong>My Products</strong> tab on the left sidebar; or</li>
<li>Click on the <strong>My Hosting Accounts</strong> under the <strong>Hosting</strong> tab in the upper navigation bar.</li>
</ul>
</li>
<li>In your hosting account list, under <strong>Control Panel</strong> column, click on the <strong>Manage Account</strong> link to open the Hosting Control Panel window.</li>
<li>From within the Hosting Control Panel, click on the <strong>Statistics</strong> heading.</li>
<li>click on the <strong>Configure Web Statistics</strong> icon.</li>
<li>Under the <strong>Password Reset</strong> heading, click on the link that reads "Have your web statistics password emailed.".</li>
</ol>
<p>And that's it. Even though it is disguised as a statistics package password, it is really your hosting account password. And just that simple, you have your hosting account password in a nice, plain text, easy to read and equally easy to steal format in your inbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/24/recovering-your-godaddy-com-hosting-password/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ZendCon 2009: Day 3</title>
		<link>http://www.robert-gonzalez.com/2009/10/22/zendcon-2009-day-3/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/22/zendcon-2009-day-3/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 21:48:15 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[ZendCon]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2340</guid>
		<description><![CDATA[And so ends the Zend PHP Developers Conference for 2009...
The last day of ZendCon is always a mixed bag when it comes to wrapping things up. On the one hand you, as a programmer, are loving the learning and education and networking and mixing things up with your peers. But on the other hand you, [...]]]></description>
			<content:encoded><![CDATA[<p>And so ends the Zend PHP Developers Conference for 2009...</p>
<p>The last day of ZendCon is always a mixed bag when it comes to wrapping things up. On the one hand you, as a programmer, are loving the learning and education and networking and mixing things up with your peers. But on the other hand you, as a regular person, are tired from all the learning and education and networking and mixing things up with your peers (and drinking... and eating... and more drinking). Still, when all is said and done, all good things must come to an end. And so it goes with ZendCon.</p>
<p>Today started out pretty much the same as the other days except we knew we were in for a half day of sessions instead of a whole day. With that we chose the sessions we wanted to attend and headed for our rooms.</p>
<p><strong>Session 0: Design Patterns for PHP developers</strong><br />
This was the second talk of Cal's that I attended this ZendCon and, much like the first, Cal gave a great presentation on Design Patterns for PHP. Covering the basics of design patterns, he made sure to mention the most important patterns we could use, like Factory, Strategy, Observer, Model-View-Controller, Facade and Singleton. He made the samples very easy to understand and was quick to answer the questions asked of him.</p>
<p>Design Patterns have a special place in my heart as a programmer (I have given talks to local meetup groups about design patterns) and I love how knowing design patterns levels out the disparity between programming languages. Knowing them makes one language for all programmers and allows anyone from any language background to be able to communicate programming concepts and paradigms in a common tongue, if you will. That said, Cal delivered big-time in his talk on patterns. He also inspired me to pursue my ambition of putting together a PHP Design Patterns web site for developers that have not seen, or do not understand, design patterns applied to PHP.</p>
<p><a href="http://blog.calevans.com/wp-content/uploads/2009/10/Design-Patterns.pdf">Slide for Cal's presentation can be downloaded here. (.pdf)</a></p>
<p><strong>Session 1: Authorization with OAuth</strong><br />
Rob Richards gave a talk about OAuth and the difference between authentication and authorization. He moved pretty quickly into an actual implementation of using OAuth for authentication of a user from an application and, in my opinion, moved a little too fast into too concrete of an implementation. Still, the presentation was very informative and useful for anyone that is thinking of utilizing OAuth as an authentication mechanism.</p>
<p><strong>Day 3 &#038;& ZendCon wrap-up</strong><br />
I was a little saddened to see the end of the conference come up so fast. Still, I am glad its over because I can use the rest.</p>
<p>I'm thinking next year I want to see if I can get in on giving a talk. I'd love to present and would love to not have to pay to get into the conference <img src='http://www.robert-gonzalez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . I also think that it would be freaking awesome to have a small group of the guys I have met over the last two hears at ZendCon over to my home for a BBQ or something, though I should probably bring that up with my wife before I even think of doing anything like that (I will honey, I promise <img src='http://www.robert-gonzalez.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). </p>
<p>Overall, this year's conference was better than last years in a couple of ways. First, the subject of many of the talks was <strong><em>NOT</em></strong> scaling. That, in and of itself, made this conference better than last year. </p>
<p>Second, the location was also a bit better than last year, being closer to downtown and all that being in downtown has to offer. </p>
<p>On the other hand, this year's conference was deficient in several area. First off, the lack of power in the lobby and in the conference rooms was painful. Having a laptop battery with only a 38% capacity made it difficult to attend a session that didn't have sufficient power.</p>
<p>Secondly, the vendor fair this year kinda sucked. It was nice to have them there, as always, but they didn't seem to want to interact with people this year. The shirts were awesome and the shwag was also very nice -who doesn't like free, right? Still, I think having more relevant vendors with more accessibility to relevant and pertinent information would have been nice.</p>
<p>Regardless, I got nothing but love for the organizers of this conference. Specifically, kudos need to go out to <a href="http://eliw.com/">Eli White</a> (<a href="http://twitter.com/eliw">@eliw</a>) for his incredible support of the conference and attendees, and <a href="http://caseysoftware.com/blog">Keith Casey</a> (<a href="http://twitter.com/caseysoftware">@CaseySoftware</a>) for the indescribable work he does on the conference uncon sessions. I cannot wait for ZendCon2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/22/zendcon-2009-day-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ZendCon 2009: Day 2</title>
		<link>http://www.robert-gonzalez.com/2009/10/21/zendcon-2009-day-2/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/21/zendcon-2009-day-2/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 01:13:16 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[ZendCon]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2326</guid>
		<description><![CDATA[Yesterday was an amazing day at ZendCon. Lots of talks, lots of information, lots of networking, lots of geekdom. The day was long but very informative and at the end of it I couldn't wait to get back for today.
Today started off a bit different than yesterday because today I was scheduled to take the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday was an amazing day at ZendCon. Lots of talks, lots of information, lots of networking, lots of geekdom. The day was long but very informative and at the end of it I couldn't wait to get back for today.</p>
<p>Today started off a bit different than yesterday because today I was scheduled to take the Zend Framework Certification exam and my coworker was scheduled to take the Zend Certification Exam. So we got to the conference and camped out for the morning to get some last minute studying in. </p>
<p>As we studied we were joined by Aaron Wormus. I'm not sure why, but when presenters and other people who are widely known in PHP are close by I always feel like I am in the presence of a celebrity. Last year I was like a little kid at a football game, meeting everyone, shaking hands, being excited, enjoying the conference. This year? Well, kinda the same, except I haven't seen to have as much time this year to find people to meet.</p>
<p>Still, it was nice to be able to spend a couple of hours trying to familiarize myself with the Zend Framework. The exam preparation study guide is 214 pages long, and as of 12:15, when it was lunch time, I had gotten through about 110 page of it. So much for being totally prepared for the exam.</p>
<p>After lunch was over my coworker and I headed to the exam room where we took our test. And wouldn't you know it... I passed. So now I am not only a Zend Certified PHP Engineer, I am also Zend Framework certified as well. Sweet!</p>
<p>After the certifications were over we were able to get back into the swing of the sessions...</p>
<p><strong>MySQL Server Performance Tuning 101</strong><br />
Cal Evans, filling in for Legaya Turmelle, did an excellent job of describing how to optimize your MySQL server and sent queries to enhance the performance of your applications. Filled with an incredible amount of technical data, this presentation was still a vibrant session that involved the attendees throughout the entire session. And I managed to sneak away two things that will be a help to me as soon as I get back to work:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Show all of your global variables */</span>
mysql <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SHOW</span> GLOBAL <span style="color: #993333; font-weight: bold;">VARIABLES</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">/* Show your statuses */</span>
mysql <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SHOW</span> GLOBAL <span style="color: #993333; font-weight: bold;">STATUS</span>;</pre></div></div>

<p></code></p>
<p>Both of these can filter your queries by adding a "LIKE '%{filter}%'" to the query. Very handy pieces of information.</p>
<p><strong>Architecting Your Models</strong><br />
Matthew Weier O'Phinney gave an awesome talk about architecting models (the M in MVC) and using your models to handle business logic. The logic that was employed was very similar to the <em>Introduction to Zend Framework</em> talk he gave on Monday (kudos for consistency) and covered data access, table/row gateways and service layers.</p>
<p>This is one of those presentations that I would recommend you get the slides for because just the programming practices employed in his presentation make it an absolutely stellar session and one that can only help you as a programmer. <strong>[Note: as soon as the links to the slides are posted I will put that link here. Sorry.]</strong></p>
<p><strong>Building Desktop RIAs with JavaScript and PHP</strong><br />
<a href="http://funkatron.com/">Ed Finkler</a> gave a sweet presentation on taking PHP and Javascript from the web to the desktop in his talk on building Rich Internet Applications. His talk was dynamic, funny, had a couple of well handled snafus and totally captivated the audience.</p>
<p>Using Adobe AIR, Appcelerator's Titanium and PHP, he built a couple of cool little desktop apps that are driven by server hosted PHP applications. Though the apps were just for example, what you can do with AIR or Titanium, jQuery and PHP is freaking amazing and I can't wait to try some of this stuff when I get back to work.</p>
<p>Links to his presentation and associated code samples:
<ul>
<li><a href="http://funkatron.com/content/codeworks09-riaphpjs.pdf">Slides (.pdf)</a></li>
<li><a href="http://funkatron.com/content/codeworks09-riaphpjs-client.zip">Client code (.zip)</a></li>
<li><a href="http://funkatron.com/content/codeworks09-riaphpjs-server.zip">Server code (.zip)</a></li>
</ul>
<p><strong>Day 2 wrap-up</strong><br />
Sitting here, at the end of the last session, I am overwhelmed with the amount of information I learned in the last couple of days. I am so looking forward to how ZendCon will be wrapping up tomorrow and cannot wait to meet some of the people of I haven't yet had a chance to meet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/21/zendcon-2009-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZendCon 2009: Day 1</title>
		<link>http://www.robert-gonzalez.com/2009/10/20/zendcon-2009-day-1/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/20/zendcon-2009-day-1/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 02:07:38 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[ZendCon]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2322</guid>
		<description><![CDATA[The second day of ZendCon is always a busy day. That is the day the sessions start; when you try as hard as you can to be in three places at once; where you spend half of each session reading Twitter for all #zendcon hash tags or hang out on the #zendcon IRC channel; when [...]]]></description>
			<content:encoded><![CDATA[<p>The second day of ZendCon is always a busy day. That is the day the sessions start; when you try as hard as you can to be in three places at once; where you spend half of each session reading <a href="http://twitter.com/#search?q=%23zendcon">Twitter for all #zendcon hash tags</a> or hang out on the #zendcon IRC channel; when all you can think of outside of PHP is free swag and free beer.</p>
<p>Today was like that for me. Well, minus the mad rush to sit in on the morning keynote. I spent the early morning reading up on the Zend Framework so I can stand a chance at passing the ZF Certification Exam tomorrow. There is a lot to learn in that stupid manual (214 pages long - gripes!) so there was naturally lots of reading to do. After that we started the day.</p>
<p><strong>Session 0: PHP 5.3 = Awesome</strong><br />
<a href="http://ilia.ws">Ilia Alshanetsky</a> gave this talk on PHP 5.3 and some of the new and exciting features in it. Outside the fact that Ilia never stops talking... I mean never... this talk was filled with some pretty cool stuff that a lot of programmers have been waiting for in PHP.</p>
<p>He opened with talking about namespaces and how they can be used. There are so many ways to utilize the namespace feature that to repeat that here would take a lot of screen real estate. I would recommend getting your hands on <a href="http://ilia.ws/archives/208-PHP-5.3-Awesome-Slides.html">the slides of the presentation</a> and reading through the first few slides. There is lots of useful information on namespaces in the slides.</p>
<p>The next thing he talked about was the new usage for the ternary operator. While there are, I'm sure, different ways to implement this feature, the manner in which it is implemented right now is pretty neat. Essentially you can now say "If the first condition evaluates to true, use it, otherwise use the second" without saying it exactly that way:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// We used to do this with ternary</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span> ? <span style="color: #000088;">$a</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$b</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Now we can do this</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span> ?<span style="color: #339933;">:</span> <span style="color: #000088;">$b</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p></code></p>
<p>That is pretty slick in my opinion. </p>
<p>There was also mention of the use, internally, of the MySQLInd client library for MySQL Database Server interaction and how much overhead is being saved on select queries when not manipulating SELECT query result set data. Essentially you can cut your memory consumption in half because of this change. Sweet.</p>
<p>After this the talk moved into some new stuff you can do with INI files and data you can set in them. This change will make configuration pretty freaking sweet in my opinion, just because of what you can set and how you can set it. There is also some pretty nifty stuff that is happening with the DataTime built in objects in PHP. And lastly, there is a new PHP constant being introduced. That constant is <strong>E_DEPRECATED</strong> and it will be used to tell you, when you have error_reporting set to E_ALL, if what you are using in PHP 5.3 is slated for deprecation in PHP 6.</p>
<p>Overall this was an awesome talk. Ilia is a great speaker, knows his stuff very well and packs in about three hours worth of presentation into about an hour.</p>
<p><strong>Session 1: Xdebug — PHP developer's swiss-army knife</strong><br />
Presented by <a href="http://derickrethans.nl/">Derick Rethans</a>, the author of xDebug, this presentation covered an enormous set of the features included in xDebug. Derick also talked about kcachegrind and utilizing xDebug with PHPUnit to cover many aspects of unit testing and debugging</p>
<p><a href="http://derickrethans.nl/talks.php">Slides for Derick's talk are available for download at his website.</a></p>
<p><strong>Session 2: Mastering OpenXML Documents with PHP</strong><br />
<a href="http://www.wormus.com/aaron/">Aaron Wormus</a> gave an excellent talk about the PHPExcel library and how it utilizes the OpenXML standard to write complex and feature rich spreadsheets for Microsoft Excel, Open Office and other text based formats. This was very well presented session and covered several different, clearly coded examples.</p>
<p><strong>Session 3: Premature Optimization Mistakes</strong><br />
Another awesome presentation by <a href="http://ilia.ws">Ilia Alshanetsky</a>, this session talked about some of the wrong directions programmers can go into when trying to optimize their applications. Many myths were debunked in this session, like the idea that smaller code is better code, removing comments in PHP makes your applications faster and changing your code makes it better. I even installed APC on <a href="http://forums.devnetwork.net">the PHP Developer's Network forums</a> during this presentation to buy some performance gain without having to do any really heaving lifting.</p>
<p>Again, Ilia put about three hours worth of information into an hour long session and knocked it out of the park. </p>
<p><strong>Session 4: Taming the Deployment Beast</strong><br />
Chris Cornutt, the man behind <a href="http://phpdeveloper.org/">PHPDeveloper.org</a> and <a href="http://joind.in/">joind.in</a>, gave a hugely informative presentation about deployment and managing your applications from the start of development to the implementation of production over both teams of developers and for individual programmers. </p>
<p>Covering an array of various tools, practices and principles, Chris's presentation was filled with application lifecycle management concepts, deployment practices and low level programming practices.</p>
<p><a href="http://www.slideshare.net/ccornutt/taming-the-deployment-beast-2311881">Slides can be downloaded here</a></p>
<p><strong>Day 1 wrap-up</strong><br />
Much like last year, the first day of ZendCon was packed with information, networking, free swag (thank God for vendor fairs) and great food. Seriously%2</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/20/zendcon-2009-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZendCon 2009: Day 0</title>
		<link>http://www.robert-gonzalez.com/2009/10/19/zendcon-2009-day-0/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/19/zendcon-2009-day-0/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 02:54:51 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[ZendCon]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2294</guid>
		<description><![CDATA[Woo to the frickin' hoo! ZendCon 2009 is back in town!
I am fortunate enough to work for a company that believes that you should continue your education within your professional field. They back up that commitment by putting their money where their mouth is and actually spending money to send their employees to various training [...]]]></description>
			<content:encoded><![CDATA[<p>Woo to the frickin' hoo! ZendCon 2009 is back in town!</p>
<p>I am fortunate enough to work for a company that believes that you should continue your education within your professional field. They back up that commitment by putting their money where their mouth is and actually spending money to send their employees to various training seminars and conferences throughout the year. And this year, like last year, <a href="http://www.zendcon.com/" title="ZendCon: Only the most awesomest PHP developers conference ever">ZendCon</a> is that conference for me.</p>
<p>Like last year, this year opened up with the conference tutorials day. This year I chose to focus on <a href="http://framework.zend.com/" title="Zend Framework, the PHP framework from the PHP people">Zend Framework</a> and learning what I could of it. It is a fast growing framework and is quickly becoming a popular tool in the arsenal of many a PHP developer. I am seeing more and more recruiter emails that are asking for ZF experience. And it is a beast of a code base, well written and extremely well organized, developed by a team of people that are some of the biggest and brightest names in PHP development around the world.</p>
<p><strong>Session 0</strong><br />
My day started out with an <a href="http://joind.in/talk/view/878">Introduction to Zend Framework</a> by <a href="http://weierophinney.net/matthew/">Matthew Weier O'Phinney</a>. Matthew gave a stellar presentation on using the Zend Framework to develop a pastebin application. Covering some of the ins and outs of the MVC architecture employed by the Zend Framework, he also taught some programming practices as he started out first by developing his models, then his forms, then his controllers then his views. He taught techniques like setting view variables as their lowest PHP variable type so they are not to tightly coupled to a particular implementation should controllers or models change (like passing a result array to the view as opposed to a DB result object).</p>
<p>He also went into a decent amount of detail on Zend_Tool, Zend_Config, plugins and routing. In the end I felt like I could actually do something cool with the Zend Framework. Maybe not as cool as what he did, but cool nonetheless.</p>
<p>Now if I could just figure out those sweet vim plugins he was using...</p>
<p><strong>Session 1</strong><br />
Seeing as the Zend Framework certification exam is being offered to conference attendees for free I figured since I am here that I would try to add to my ZCE certification. To do that I figured I'd sit in on the <a href="http://joind.in/talk/view/882">Zend Framework Certification Refresher</a> course being presented by <a href="http://akrabat.com/">Rob Allen</a>.</p>
<p>I am pretty sure I was in over my head from the start of this class. One of the first things that Rob said was that this class was not a tutorial on Zend Framework but a refresher for those that are using it regularly. For almost every component that was covered he asked the question "Who has used this?" and sadly I could not raise my hand for hardly any of them. Still, on the practice questions I did alright because much of the Zend Framework is common enough that you can expect certain behavior from it. That seemed to get me some pretty good mileage.</p>
<p>Of course there were lots of things that I had never seen, either. Parts of Zend_Log (and the writers, the formatters and the filters), parts of Zend_Db (the table data gateway and the row data gateway), Zend_Auth (the returns from Zend_Auth::authenticate()) and a host of other items from the framework are fodder for me reading up on.</p>
<p>Still, I think I can pass the exam if I don't overthink the questions being asked. Of course, that means lots and lots of reading tonight, tomorrow, tomorrow evening and Wednesday morning.</p>
<p><strong>Other happenings (and mishappenings)</strong><br />
When my coworker and I got to the conference and registered that we were there we noticed something missing from our registration packet. All early registrants who attended a previous ZendCon were supposed to receive a netbook for the conference. Ours was not there. Throughout the day we checked back in with the front desk, per their instruction, and found out at the end of the day that we would be getting ours tomorrow. That was a small bummer, though it had a happy ending so I am pretty stoked about that.</p>
<p>Something else I noticed this year was the lack of power in the rooms. Last year there was no shortage of power plugs to plug my laptop into. This year, in the first session, only the people that sat next to the walls close to an outlet could plug in. The second session was a little better in that my room had two power strips. Still, both of those were on one side of the room so if you sat on the other side of the room for the three hour session there was a decent chance that you were going to be running out of power before the end of the session.</p>
<p>Wireless internet this year was way better than last year for me (albeit a lot slower). Connecting to it was a snap and once I was able to power up my laptop I was able to stay connected to the internet pretty much the entire rest of the day.</p>
<p>Lunch was really good this year. For a boxed lunch the food was really, really good. As were the dining accommodations. My coworker and I were able to meet some new folks (a fellow from Seattle, John from Vermont and another fellow from Slovenia) as we talked about the ZCE, differences between PHP and Java and this year's conference versus last year's.</p>
<p>Ending the day this year was a little sad for me. Not because the day was over and I had to wait an entire half a day to mingle with my peers again. No, it was because of the $18 I spent on parking at the Convention Center. What. The. Hell? There was no validation either. And to top it off, the stupid ticket reader didn't work so we had to drive around the entire garage until we found a guy that could help us.</p>
<p>Still, given the day as it went, I am very happy with ZendCon this year. I cannot wait until it gets into full swing tomorrow. And I really can't wait for some of the uncons that were just posted late tonight.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/19/zendcon-2009-day-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling multiple MySQL results in PHP</title>
		<link>http://www.robert-gonzalez.com/2009/10/16/handling-multiple-mysql-results-in-php/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/16/handling-multiple-mysql-results-in-php/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 00:10:17 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Stored Procedures]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2264</guid>
		<description><![CDATA[Back in the day (June of 2007 to be a little more exact) I posted a little snippet about using PHP to hand multiple MySQL query results with the MySQLi extension. At the time it was something I was using just to see what was coming back from the database when I called a stored [...]]]></description>
			<content:encoded><![CDATA[<p>Back in the day (June of 2007 to be a little more exact) I posted a little snippet about <a href="http://www.robert-gonzalez.com/2007/06/01/mysql-multiple-result-procs-in-php/" title="Man, that post was popular">using PHP to hand multiple MySQL query results with the MySQLi extension</a>. At the time it was something I was using just to see what was coming back from the database when I called a stored procedure that happened to have multiple results in it. <a href="#under-the-hood" title="Show me the money">Skip to how this <em>really</em> works...</a></p>
<p>Since then I have improved my little handler, added some library code to actually handle queries and results (and timers and requests and... dude, so much). The new code, which is much fatter (not necessarily better, just fatter in that it has a lot more features in it), now encapsulates much of what the original, simple script was doing. Unfortunately, the script is no longer as simple as I wanted it to be. However, it does now come in several files which might be of use to you in some of your own code.</p>
<p>Because of the change that I made to the way this code works, I have decided to package it into <a href="http://www.robert-gonzalez.com/personal/code/php-mysql-multiple-results.zip" title="Zip it! Zip it good!">a little zip file for your downloading pleasure</a>. The zip file includes:
<ul>
<li>index.php (the actual procedure/result tester)</li>
<li>A lib directory, which contains:
<ul>
<li>memorystats.php (A memory use and reporting object)</li>
<li>mysql.php (The database connection and query object)</li>
<li>mysqlresult.php (The database result object)</li>
<li>request.php (The HTTP request object)</li>
<li>timer.php (The process timer object)</li>
</ul>
</li>
</ul>
<p>It should be ready to use right out of the box, with the exception of making sure to add your own username, password and database name to the $db->connect() call (at about line 85 in index.php). I'm sure you could expand it to be more of what you want in a tester (like adding a database chooser to it - right now I have a database server chooser, but not a database chooser within a server) but overall it is a very nice little script that does pretty much what it was built to do: run a query/procedure and return all of the results in it.</p>
<p><strong>Please note: This is seriously not something that you should think to use in a production environment. The farthest this has ever made in any of my architectures is the dev machine. Not that the code is not good. It is just that putting something that has free form access to your database onto a production machine is, in my opinion, a remarkable stupid thing to do and I would hate to have my name associated with code that was used to exploit your business because you chose to put a huge gaping hole into your network through a simple little test script. Just sayin'.</strong></p>
<p><strong id="under-the-hood">Under the hood</strong><br />
Before diving into that mash of code I included in the zip file, it might be a good idea to see just the relevant code so you can, if you want to, just tap into the multiple result set handling of MySQL results in PHP. Without further ado...</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Set a query</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SHOW TABLES FROM `mysql`; SELECT VERSION() AS `version`; SELECT NOW() AS `date`;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Change the params to you own here...</span>
<span style="color: #000088;">$mysql</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqli<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HOSTNAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'USERNAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'DATABASE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_connect_errno</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MySQL Server connection failed: %s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">mysqli_connect_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Initialize our result set array</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** 
 * Check our query results
 * 
 * This is where the magic happens, and it must be this way anytime you use a
 * stored procedure. The reason for that is the MySQL server always sends a 
 * status return with any query, even a select query. That means that even a
 * single result set select query will return two results. Those results will
 * not necessarily make it to your application (I think the client handles 
 * that) but in my experience I have always had to use multi_query to get this
 * to work.
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">multi_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Create the records array</span>
		<span style="color: #000088;">$records</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Lets work with the first result set</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mysql</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">use_result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Loop the first result set, reading the records into an array</span>
			<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_array</span><span style="color: #009900;">&#40;</span>MYSQLI_ASSOC<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$records</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Close the record set</span>
			<span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Add this record set into the results array</span>
		<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$records</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">next_result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Close the connection</span>
<span style="color: #000088;">$mysql</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set our output type</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: text/plain'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// What do we have</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code></p>
<p>And there you have it. Nice, simple, clean and easy to use all by itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/16/handling-multiple-mysql-results-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scope? Nope. Dope!</title>
		<link>http://www.robert-gonzalez.com/2009/10/13/scope-nope-dope/</link>
		<comments>http://www.robert-gonzalez.com/2009/10/13/scope-nope-dope/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:56:29 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Apache Server]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[n00B]]></category>
		<category><![CDATA[Stupid]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=2255</guid>
		<description><![CDATA[Today I made a classic blunder in PHP programming. It is one that many make and certainly one I have made before. But the frustrating thing about this issue is it probably would have been caught by a simple unit test or, in lieu of that, something as simple as trying to capture output of [...]]]></description>
			<content:encoded><![CDATA[<p>Today I made a classic blunder in PHP programming. It is one that many make and certainly one I have made before. But the frustrating thing about this issue is it probably would have been caught by a simple unit test or, in lieu of that, something as simple as trying to capture output of my script from the go.</p>
<p>I was working on the command line (something I have been spending a lot more time doing) building a background processing application that will be triggered by the web. The process is expected to take between 45 minutes and an hour each time it is ran and will be ran one time a month at the discretion of an administrator (hence the reason it is not set as a cron job).</p>
<p>One of the very first lines of the CLI script looks like this:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Define our path for all includes and file writes</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPPATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p></code></p>
<p>It would seem simple enough, right? Basically that little line of code defines a constant called <strong>APPPATH</strong> that would essentially describe the path to the location of the file that is setting the constant. At least that is what I thought. And every test I ran led me to believe that I had indeed made the right choice to set the path the way I did.</p>
<p>I ran the script, and even other scripts that derived code from the script, from the command line on my local Ubuntu machine, from the command line on our Fedora dev machine and from the command line on our Ubuntu production server. I have similar snippets that are working on all of our machines, and these snippets work interactively, through cron and through the web.</p>
<p>But today something happened that I did not intend. As I attempted to run my last process test of this long running script through the web I found myself in a place where my script would not run. It was being triggered properly. It was just not actually doing anything. </p>
<p>After an hour of trying to figure out what I was doing wrong I solicited the wisdom and advice of two of my colleagues who are seasoned Unix professionals and after a couple of minutes I was able to begin to see what was wrong. Can you guess what it was?</p>
<p>That's right... PHP, on the web, was applying its scope to the CLI script that it was calling. The reason it had worked in all cases prior to triggering it by the web was that I was logged in as me and calling the script as a CLI script interactively, through the prompt. That means that the setting of the <strong>APPPATH</strong> constant was happening as expected and to what I expected.</p>
<p>However, from the web, when PHP runs as an apache module, it calls the CLI script from the scope of the web server. That means that the use of <a href="http://us.php.net/realpath" title="Get the canonical path to a location on the file system in PHP">realpath()</a> on the location '.' (current working directory) was assuming the working directory was the web server root, not the location of where the script actually resided.</p>
<p>That's right folks, I lost track of the scope in which I was working. Like a dope.</p>
<p>The simple solution to this problem was to change where the script looks to set its own directory. Can you think of what I could have used, instead of '.' as the location to pass to realpath() so that it knows, without a doubt, what its own path is?</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Get the real path to the current directory location OF THIS FILE</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPPATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p></code></p>
<p>I hate it when something this simple causes such deep pain and suffering, needlessly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/10/13/scope-nope-dope/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting books details by ISBN in PHP</title>
		<link>http://www.robert-gonzalez.com/2009/04/04/getting-books-details-by-isbn-in-php/</link>
		<comments>http://www.robert-gonzalez.com/2009/04/04/getting-books-details-by-isbn-in-php/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 01:21:05 +0000</pubDate>
		<dc:creator>Robert Gonzalez</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.robert-gonzalez.com/?p=1955</guid>
		<description><![CDATA[Sometimes I love being a geek. Today, as I set out to inventory my collection of almost 500 books or so, I wanted to find a fast way to get the information on the book I wanted based on the books ISBN. This was because I was already getting tired of typing five books into [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I love being a geek. Today, as I set out to inventory my collection of almost 500 books or so, I wanted to find a fast way to get the information on the book I wanted based on the books <a href="http://en.wikipedia.org/wiki/ISBN_Number" title="ISBN: International Standard Book Number">ISBN</a>. This was because I was already getting tired of typing five books into the inventory (yes, I am that lazy) and I really did not want to keep typing out the authors name, the title and the subtitle for each book.</p>
<p>So I went to <a href="https://isbndb.com/" title="The ISBN database">ISBNdb.com</a> and entered an ISBN thinking I would be able to just copy and paste the book information from the output. That turned out to be overwhelmingly difficult since their output of the search is really convoluted. I knew what I wanted to get and they didn't offer that.</p>
<p>But they did offer an API and, after reading their docs, I realized that I could write a script that would take an ISBN and return to me the information I was looking for in a way that I could just copy and paste it. Remarkably, it was faster and easier than I thought it would be. I actually developed this little snippet, freely available for you here, in about 5 minutes. Hope it helps you in some way, if you are looking for such a thing.</p>
<p>NOTE: Before using this code make sure to sign up for your own API key. In order to do that you will need to register for an account with ISBNdb.com and then create a key. But as soon as you do you will have immediate access to their API. The API is simple, responding to the request with a simple XML output. Anyhow, without further ado, here is the little script I put together to fetch me the data I was looking for the way I wanted it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Set this value to your own API key
 */</span>
<span style="color: #000088;">$apikey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'12345678'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Initialize this var for use when forms are not posted
 */</span>
<span style="color: #000088;">$isbn</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Initialize the result set var
 */</span>
<span style="color: #000088;">$rs</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * See if the form is posted
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'POST'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009933; font-style: italic;">/**
   * Get the ISBN from the form
   * 
   * No, there is no validation on this. This 
   * was for me and I knew I would not be at
   * all trying to trick my own script. USE 
   * THIS AS IS AT YOUR OWN PERIL.
   */</span>
  <span style="color: #000088;">$isbn</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'isbn'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009933; font-style: italic;">/**
   * Get the result as a SimpleXML object
   */</span>
  <span style="color: #000088;">$rs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://isbndb.com/api/books.xml?access_key=<span style="color: #006699; font-weight: bold;">$apikey</span>&amp;index1=isbn&amp;value1=<span style="color: #006699; font-weight: bold;">$isbn</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;html&gt;
&lt;head&gt;&lt;title&gt;ISBN Check&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;form method=&quot;post&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
  &lt;p&gt;
    Enter an ISBN:&lt;br /&gt;
    &lt;input type=&quot;text&quot; size=&quot;40&quot; name=&quot;isbn&quot; id=&quot;isbn&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$isbn</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search ISBN&quot; /&gt;
  &lt;/p&gt;
&lt;/form&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Only output more stuff if there is a result
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;hr /&gt;
Results for ISBN: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$isbn</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #009933; font-style: italic;">/**
 * Results for a book are in $rs-&gt;BookList-&gt;BookData
 * 
 * You can see this using var_dump($rs);
 */</span> 
<span style="color: #000088;">$book</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rs</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">BookList</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">BookData</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;p&gt;
  &lt;strong&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Title</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TitleLong</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TitleLong</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AuthorsText</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">PublisherText</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$isbn</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Typical output might look like (from one of the books I was checking on):</p>
<hr />
Results for ISBN: 0316116955:</p>
<p><strong>The day the universe changed</strong><br />
James Burke<br />
Boston : Little, Brown, c1985.<br />
0316116955</p>
<hr />
<p>I hope you enjoy this, if you happen to be looking for an ISBN search tool that you can run on your own. <img src='http://www.robert-gonzalez.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robert-gonzalez.com/2009/04/04/getting-books-details-by-isbn-in-php/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
