From desktops to servers, find the right IT Support for your business.

Last Updated 23/Sep/2009

Review: Build Your Own Database Driven Web Site Using PHP and MySQL

Iain Laskey thinks this new book is an excellent introduction to database driven web sites

Product Build Your Own Database Driven Web Site Using PHP and MySQL (4th Edition)
Company Sitepoint
Web www.sitepoint.com
Price £31.49
We like Structure, security aware techniques, clear explanations, real world advice
We don't like Nothing
Rating 10/10
Requirements  

Kevin Yank's latest edition of 'Build Your Own Database Driven Web Site using PHP and MySQL' does exactly what it says on the tin. The book is aimed at intermediate to advanced web site developers who want to make the move to server side programming and as the title suggests, database driven web sites in particular. The author says no knowledge of CSS, PHP or Javascript is required but a little won't hurt.

Usefully, the book starts with a clear step by step guide on building your development environment including web server, PHP and MySQL on a number of platforms. This includes some important post installation tasks and some recommendations on free IDEs (Integrated Development Environments) you can download.

Chapters 2 and 3 introduce the basics of MySQL and PHP respectively. The explanations are clear and concise and illustrations help clarify important concepts.

Chapter 4 covers using PHP to work with the database - retrieving data, finding out about the number of affected rows, putting the information on the page and so on. The example project used throughout the book is a jokes database. Early on, the author stresses the importance of writing defensive code to keep hackers at bay. For instance, don't just accept user input from a form and put it in the database - check for anything that could cause problems. Luckily, PHP has some useful library functions for just this task. As well as coding defensively, the author also stresses making code as portable as possible - something many books leave off until later.

Chapter 5 is a short primer on database design. It covers all the basics but if you're intending any serious sort of database, we'd recommend buying another book on database design to ensure you don't back yourself into a corner further down the line.

Chapter 6 introduces structured programming and emphasises reusable code, include files, function libraries and other ways to improve productivity and simplify maintenance - a bugbear on larger sites.

Chapter 7 is where the real action starts and introduces the Content Management System (CMS). A CMS gives you the ability to control who does what and allows users to create their own content without having to worry about the intricacies of SQL or PHP. Separating content creation from the operational side also adds further layers of security making your web site safer. Here you'll see how to create users, new content, add categories to content and control who does what including removing old content.

Having content is all well and good but you want it to look presentable so Chapter 8 describes how to format the output. To achieve this, the book uses 'regular expressions' to search for and change strings of text. At a simple level, this will include recognising when a user hit return entering text and adding </p><p> to the string at that point. The chapter uses the common BBCode format used on many sites for adding bold, italic and so on to any text being entered. This is then converted to the HTML equivalents when saved. More complex conversions like identifying and processing URLs to include correct markup are also described clearly.

Most sites will need to identify who you are and correctly handle your use of the site - perhaps tracking a shopping cart. This is done via cookies and session control. Chapter 8 covers this as well as adding more security techniques including scrambling passwords.

The rest of the book is mainly taken up with the database side of things - complex SQL queries, database management and how to handle binary data such as images or document files. A MySQL reference guide finishes things off.

Conclusion

We thought this was a superb book. The author, Kevin Yank is to be congratulated on producing a book that is eminently readable, well balanced in scope and perhaps most importantly, concentrates on producing real, manageable and secure sites. The explanations are clear, the code examples well thought out and the progression from simply connecting to the database through to a fully functional CMS based jokes web site is well handled. If you have any interest in building a database driven web site, we say reading this book should be your first task.

Iain Laskey

Keep up to Date with PPC

RSS feed icon

Add to Google
Free Sitemap Generator