ITWalesSoftware Alliance WalesStudent PlacementsTechnocampsComputer Science
 

Head First - PHP & MySQL

by Mark Kiddell

front cover of book Head First, as I shall refer to it, differs from most normal books on programming. It is not a PHP and MySQL in 24 hours book, nor is it an encyclopedic reference manual of every available command and how they work/interact with others. If I were to compare it with anything else it would have to be a school or college course text book.


Audience

The book pitches its target audience at someone that is already capable of making his own web page in HTML, but wants to move on from HTML’s basic BrochureWare capabilities to projects that can be much larger, with dynamic content, whilst also being easier to update and maintain than small HTML sites.


Technology

Both PHP and MySQL require server software for them to run on. Head First explains how to set up your own Web Server, how to download and install both PHP and MySQL, and how to get it all working on your home computer Mac and Windows so that you’re not left with a book that is basically a doorstop until you get some commercial webhosting.


The Web

One thing that immediately struck me as a benefit of this book over many others is they have a website related to it at http://www.headfirstlabs.com/books/hfphp/. From this site you can download all the examples given in the book, eliminating lengthy manual copying of text in the book itself. There is also a forum that is very busy and covers many issues people have had related to the examples in the book - and solutions to their problems.


The Book

open book showing diagrams The book relies an awful lot on pictures and diagrams to get the message across to the reader. They do say a picture is worth a thousand words, and in this case a few simple diagrams are far more effective than page upon page of written explanation.

I can see how for the novice PHP programmer this is a far better approach particularly if you’re looking back to refresh your memory on how something is done a week later - it takes seconds to look at a simple diagram and understand it.

Once an idea has been shown using diagrams such that the reader has the basic concept Head First moves on to coding a PHP page.

The page starts as a basic example and builds to something more complicated over following pages, with intentional errors thrown in. The idea behind the errors is to prevent you from just skim reading the section and makes you go back and really understand the code to find the problems.

At the end of many of the pages of the book, questions are asked with no definite answers, although a solution will often follow on the next page in the form of the next topic. This format of questions and answers keeps you thinking and interested in what the book is showing you, and gives the book a real College Coursebook feel.

Head First really seems to shine once it moves on to MySQL, even an absolute beginner will pick up what to do in no time, yet at the same time experienced programmers will learn something from it and keep it as a quick reference guide to doing basic MySQL processes. The book is more about the process of doing things rather than what commands do.

Good real world examples are provided. At the start of the book you create a php script that accepts input from a web form and displays it in your browser window. Head First then moves on to emailing the output to a specified email address so you can put web forms on your own website. The next example is in MySQL, the data from the web form is saved to a database as well as emailed, allowing you to refer back to the forms at a later date without having to keep/find the email. These simple examples allow you to take feedback on a contact page in your website, or let people sign up for a mailing list.

Later examples in the book cover mailing lists and mailouts, allowing you to send mailouts to entire mailing lists via a simple form, http authentication to protect password protected areas of your site allowing members areas, and web security, this includes protection from SQL injection, one of the most common forms of attacks on websites.

Web applications in the book include: A guitar wars site with fully validated high scores section. A matchmaking website with custom member logins for each member, and a jobsearch website, allowing people to register, post their curriculum vitae, and search for jobs that suit them.

Head First also gives examples of syndicating content via RSS feeds, and pulling YouTube videos down to incorporate them into your web pages.

Overall I’d say this is an excellent book for people at all experience levels from beginner to regular coder. A learning book for the beginner, and a memory refresher book for those that do PHP and MySQL as a day job. There are few books out there that cover everything from "Hello World" up to regular expressions, including dynamic image generation using graphics libraries, security features such as CAPTCHA pass-phrases, and web forms with SQL injection protection.

Highly recommended.


"Head First - PHP & MySQL" is written by Lynn Beighley & Michael Morrison, and is published by O’Reilly.
The book is available at a RRP of 34.50, 36, $44.99.