
Notes on This Edition
The entire contents of this edition of the book were updated to correspond to version 5.3 of PHP and version 5.5 of MySQL. Approximately 50% of the material requires version 5 or later of PHP, mostly because the book only uses the Improved MySQL functions, added in PHP 5 and MySQL 4.1. Another 10% or so of the material requires version 5.3 of PHP, although in those instances, I do provide alternative code for earlier versions of the language.
In terms of what’s new, there are three entirely new chapters. Chapter 6: Database Design takes some material out of a couple of chapters in the previous edition, breaks it down into smaller steps, and creates a more cohesive discussion of every key facet of database design. Chapter 15: Introducing jQuery is entirely new, introducing JavaScript and the jQuery framework. The examples include form validation, event handling, and Ajax. Chapter 16: An OOP Primer is also entirely new, discussing the basics of object-oriented programming in PHP. The focus is really on basic ideas and syntax, using existing classes (OOP design and theory requires too many pages to fit into this book).
In terms of revised content, every chapter now ends with a “Review and Pursue” section which asks questions that stress key points and provides prompts for how you can expand upon the information you just learned. A few chapters use new examples, mostly because I was bored with the existing ones. Chapter 7: Advanced SQL and MySQL has expanded coverage of JOINs, a new section on advanced selections, and more. In fact, updating and expanding the MySQL and SQL content was a key change in this edition. Chapter 11: Web Application Development is heavily rewritten, putting more emphasis on the use of JavaScript in the example application partially developed in that chapter. Chapter 13: Security Methods has two new security examples: using the Filter extension and validating file uploads by type. Finally, Appendix A: Installation has a new section on Apache server configuration. To save space, the Appendix is being made available for free online from the book’s publisher, Peachpit Press (I’ll provide more details once I have them).
- Introduction
- Chapter 1: Introduction to PHP
- Basic Syntax
- Sending Data to the Web Browser
- Writing Comments
- What Are Variables?
- Introducing Strings
- Concatenating Strings
- Introducing Numbers
- Introducing Constants
- Single vs. Double Quotation Marks
- Basic Debugging Steps
- Review and Pursue
- Chapter 2: Programming with PHP
- Creating an HTML Form
- Handling an HTML Form
- Conditionals and Operators
- Validating Form Data
- Introducing Arrays
- For and While Loops
- Review and Pursue
- Chapter 3: Creating Dynamic Web Sites
- Including Multiple Files
- Handling HTML Forms, Revisited
- Making Sticky Forms
- Creating Your Own Functions
- Review and Pursue
- Chapter 4: Introduction to MySQL
- Naming Database Elements
- Choosing Your Column Types
- Choosing Other Column Properties
- Accessing MySQL
- Review and Pursue
- Chapter 5: Introduction to SQL
- Creating Databases and Tables
- Inserting Records
- Selecting Data
- Using Conditionals
- Using LIKE and NOT LIKE
- Sorting Query Results
- Limiting Query Results
- Updating Data
- Deleting Data
- Using Functions
- Review and Pursue
- Chapter 6: Database Design
- Normalization
- Creating Indexes
- Using Different Table Types
- Languages and MySQL
- Time Zones and MySQL
- Foreign Key Constraints
- Review and Pursue
- Chapter 7: Advanced SQL and MySQL
- Performing Joins
- Grouping Selected Results
- Advanced Selections
- Performing FULLTEXT Searches
- Optimizing Queries
- Performing Transactions
- Database Encryption
- Review and Pursue
- Chapter 8: Error Handling and Debugging
- Error Types and Basic Debugging
- Displaying PHP Errors
- Adjusting Error Reporting in PHP
- Creating Custom Error Handlers
- PHP Debugging Techniques
- SQL and MySQL Debugging Techniques
- Review and Pursue
- Chapter 9: Using PHP with MySQL
- Modifying the Template
- Connecting to MySQL
- Executing Simple Queries
- Retrieving Query Results
- Ensuring Secure SQL
- Counting Returned Records
- Updating Records with PHP
- Review and Pursue
- Chapter 10: Common Programming Techniques
- Sending Values to a Script
- Using Hidden Form Inputs
- Editing Existing Records
- Paginating Query Results
- Making Sortable Displays
- Review and Pursue
- Chapter 11: Web Application Development
- Sending Email
- Handling File Uploads
- PHP and JavaScript
- Understanding HTTP Headers
- Date and Time Functions
- Review and Pursue
- Chapter 12: Cookies and Sessions
- Making a Login Page
- Defining the Login Functions
- Using Cookies
- Using Sessions
- Improving Session Security
- Review and Pursue
- Chapter 13: Security Methods
- Preventing Spam
- Validating Data by Type
- Validating Files by Type
- Preventing XSS Attacks
- Using the Filter Extension
- Preventing SQL Injection Attacks
- Review and Pursue
- Chapter 14: Perl-compatible Regular Expressions
- Creating a Test Script
- Defining Simple Patterns
- Using Quantifiers
- Using Character Classes
- Finding All Matches
- Using Modifiers
- Matching and Replacing Patterns
- Review and Pursue
- Chapter 15: Introducing jQuery
- What is jQuery?
- Incorporating jQuery
- Using jQuery
- Selecting Page Elements
- Event Handling
- DOM Manipulation
- Using Ajax
- Review and Pursue
- Chapter 16: An OOP Primer
- Fundamentals and Syntax
- Working with MySQL
- The DateTime Class
- Review and Pursue
- Chapter 17: Example—Message Board
- Making the Database
- Writing the Templates
- Creating the Index Page
- Creating the Forum Page
- Creating the Thread Page
- Posting Messages
- Review and Pursue
- Chapter 18: Example—User Registration
- Creating the Templates
- Writing the Configuration Scripts
- Creating the Home Page
- Registration
- Activating an Account
- Logging In and Logging Out
- Password Management
- Review and Pursue
- Chapter 19: Example—E-Commerce
- Creating the Database
- The Administrative Side
- Creating the Public Template
- The Product Catalog
- The Shopping Cart
- Recording the Orders
- Review and Pursue
- Appendix A: Installation (AVAILABLE ONLINE)
- Installation on Windows
- Installation on Mac OS X
- Managing MySQL Users
- Testing Your Installation
- Configuring PHP
- Configuring Apache

Hi I am trying to decide which one of the two books is best for me, I am somewhat beginner at the PHP and do not know which of the two books I should buy one is newer and has sql and the other seems to have more programming instructions: I saw both of the Indexes and even though I have another PHP six book by Ed Thompson I find it a bit too complicated and lengthy I am looking for a simple to follow book yet I understand the importance of SQL I need full instruction how to load these in my PC I built a Unix Debian but then I am a PC guy and not a Unix and I need instruction where to put my web design on which directory and how do I put multiple web designs in one server or in one window I widh some body would write a book about getting the data in files in the computer every body talks about how to write php or HTML but I really do not know where and which directory I should put them for them to work. I am trying to use a home web server because I want to have 10 sites. if you can help me decide which one of your books to buy and where do i find a good book about all these that is simple to use , I would greatly appreciated. Buy the way do you sell any CDs and are the codes for this book available after I buy the book? Thanks
Albert
Hello Albert. Thanks for your interest in the book. If you’re considering buying the PHP & MySQL book, you should buy the 4th edition, which is the newest and most current. You may do better by my “PHP for the Web: Visual QuickStart Guide”, though, which goes at a much slower pace. In both books I do discuss installing PHP, MySQL, and Apache on your computer, and therefore what directories you would use. That being said, while I recommend everyone install these things on their on computer for development purposes (and they are all free), you absolutely do not want to host live sites from a home computer. At best, that will work but be impractical (e.g., your users will experience terrible performance) and unsecure. At worst, it may not be possible at all, depending upon your internet provider.
Okay, please, keeping in mind that Larry is a PHP guru and I’m a minimally competent coder at best, LOL (I’m not a programmer, I just use PHP/MySQL to do proprietary webpages in-house):
That said, I’ve been very happy doing my work by direct FTP to the server. (This does require a second monitor to be at all practical.) Once the site is live, I do a password-protected mirror site with error reporting turned on, where I test out upgrades, changes, new pages, etc.
It takes somewhat longer, since you have to upload and refresh your browser for every change. You wouldn’t want to do it if you were a full-time PHP developer. But for a part-timer/amateur, it does avoid some hassle if you rent your server space from a company, such as running into different configurations on the server vs. your machine, the hosting company screwing with configuration, etc. Plus, it avoids the initial time of installing LAMP/WAMP.
Allen,
When learning a new language I’d recommend sticking to an OS you’re familiar with to start. I tried learning PHP and Linux at the same time and it really hindered my learning of PHP with having to mess with file permissions and learn the command line along the way. Stick to Windows while you learn. In this day and age I think the compatibility issues of Windows vs Linux are greatly exaggerated and some people are still living in the past. As long as you deploy on what you develop on you won’t have any issues anyway. I’ve made a few things in Windows and deployed on Linux without any issues anyway.
Is there more security information I can learn with this new book compared to the 3rd edition? Can you explain what the new section “Using the Filter extension” is? Is that the PEAR extensions, which are described in your PHP 5 Advanced book?
Hello Luke. Thanks for your interest. Yes, there is more discussion of security in this edition, in terms of PHP, MySQL, and Apache (each individually has more security information). The Filter extension used to be in PEAR, but is now part of PHP proper. The PHP 5 Advanced book does discuss PEAR, but not Filter. Thanks again!
How do I find Appendix A. Since I am totally new to PHP and cannot use your book with out it?
See this post.