Sharon Machlis

Review: Practical PHP and MySQL

January 25, 2007 7:52 PM EST
I've got to hand it to Practical PHP and MySQL author Jono Bacon: There aren't a lot of writers who could get me to bring a book about Web development on a plane to keep from being bored. He understands that some people don't want hundreds of pages of tutorials about everything a language has to offer. Instead, Practical PHP and MySQL dives right in with a compact, efficient overview of both the PHP programming language and using a MySQL database, and follows that with some hands-on projects. Very quickly, the reader sees and dissects code that can run a blog site, followed by projects for discussion forums, a shopping card, online auctions, Web-based calendar and more.

My favorite part of the book is the beginning, where Bacon offers a brisk rundown of basics like arrays, loops and if/else statements, and also gives valuable advice on how to code along. There's a live CD included so you can boot up Ubuntu Linux and see all the projects - not only view and play with code snippets via the Bluefish programming editor (noticeably superior to the text editor I've been using to write my PHP), but also running the final applications off the disc.

One of the most useful tidbits in the book is Bacon's recommendation of the Xampp project if you want to try installing PHP and MySQL on a Windows or Linux system for the first time. It's not meant to be a hardened production environment, but does offer a handy local development setup. For readers like me who have a Web host to deal with the server side, but would prefer not to have to upload a file to that server every time they make a change and want to see the effect, Xampp is an ideal choice. I would have liked a bit more advice on Windows MySQL set-up, though, such as how to add a password for the root user (not as obvious as it should be). Considering that Bacon is Ubuntu community manager at Canonical, which sponsors the Ubuntu Linux project, it's not surprising there's a bit more focus on Linux.

I give Bacon points for integrating security issues into the book early on and throughout, instead of doing what I've seen some other authors do: offer an advanced-level chapter or two on the subject toward the end. Here, right off the bat on the first project he talks about data validation and explains things like SQL injection attacks (possible if you're careless about using data from a URL string to serve a variable to your application).

It's possible to be both readable and occasionally annoying, and I found some of the overenthusiastic comments to be a bit much ("The blog application created in this chapter is rather niftily titled Blogtastic"). More puzzling, I'm not quite sure who his audience is supposed to be, as he careens between comments like "developers such as you" (implying serious coders as readers) and "for those of you who shudder at the thought of math, fear not" (clearly implying others).

My biggest complaint, though, is that it's kind of tough to find specific answers to questions like "how do you sort and display a specific kind of data from a certain type of database design?" Clearly, this is not meant as a reference book. You've got to work through all the examples to figure out what's taught where; and even once you do, it's hard to remember where to go back to so you can apply knowledge to a project you've got in the works. Readers of a book may not be heavy users of a language for years at a time, and so can forget command formats even if we remember concepts. It would be helpful to have an easier way to look up examples.

Still, I found Practical PHP and MySQL to be a good complement to a true reference book like O'Reilly's PHP Cookbook. Practical PHP and MySQL: Building Eight Dynamic Web Applications from Prentice Hall Professional has earned a spot on my home bookshelf.