Cover image for Web database applications with PHP & MySQL
Web database applications with PHP & MySQL
Williams, Hugh E.
Personal Author:
Second edition.
Publication Information:
Sebastopol, CA : O'Reilly, [2004]

Physical Description:
xviii, 796 pages : illustrations ; 24 cm
General Note:
Includes index.
Format :


Call Number
Material Type
Home Location
Item Holds
QA76.73.P224 W56 2004 Adult Non-Fiction Central Closed Stacks

On Order



There are many reasons for serving up dynamic content from a web site: to offer an online shopping site, create customized information pages for users, or just manage a large volume of content through a database. Anyone with a modest knowledge of HTML and web site management can learn to create dynamic content through the PHP programming language and the MySQL database. This book gives you the background and tools to do the job safely and reliably. Web Database Applications with PHP and MySQL , Second Edition thoroughly reflects the needs of real-world applications. It goes into detail on such practical issues as validating input (do you know what a proper credit card number looks like?), logging in users, and using templatesto give your dynamic web pages a standard look.But this book goes even further. It shows how JavaScript and PHP can be used in tandem to make a user's experience faster and more pleasant. It shows the correct way to handle errors in user input so that a site looks professional. It introduces the vast collection of powerful tools available in the PEAR repository and shows how to use some of the most popular tools.Even while it serves as an introduction to new programmers, the book does not omit critical tasks that web sites require. For instance, every site that allows updates must handle the possibility of multiple users accessing data at the same time. This book explains how to solve the problem in detail with locking.Through a sophisticated sample application--Hugh and Dave's Wine Store--all the important techniques of dynamic content are introduced. Good design is emphasized, such as dividing logic from presentation. The book introduces PHP 5 and MySQL 4.1 features, while providing techniques that can be used on older versions of the software that are still in widespread use.This new edition has been redesigned around the rich offerings of PEAR. Several of these, including the Template package and the database-independent query API, are fully integrated into examples and thoroughly described in the text. Topics include:

Installation and configuration of Apache, MySQL, and PHP on Unix®, Windows®, and Mac OS® X systems Introductions to PHP, SQL, and MySQL administration Session management, including the use of a custom database for improved efficiency User input validation, security, and authentication The PEAR repository, plus details on the use of PEAR DB and Template classes Production of PDF reports

Author Notes

Hugh E. Williams is a software design engineer at Microsoft's Windows Live Search in Redmond, WA. Previously, he was the Associate Professor in Information Retrieval at RMIT University in Melbourne, Australia. He's published over 70 research papers and holds around 10 patents, mostly in the search engine area. When not at work Hugh likes to hang out with his family, exercise, watch Richmond play footy, and learn about baseball. Hugh has a PhD from RMIT University. His home page is .

Since the mid 1990s David Lane has worked as a software engineer and IT manager with the Multimedia Database Systems group at RMIT University in Melbourne, Australia. In that group he has helped to develop and commercialize the Structured Information Manager, a large-scale SGML/XML document repository and a high performance Web server. David has also worked with Australia's largest telecommunications company, Telstra, in areas as diverse as Satellite Communications, Human Factors Research, and Electronic Document Interchange (EDI). David has a Bachelor's degree in Applied Science (majoring in mathematics and computer science) from Swinburne University.

Reviews 1

Library Journal Review

MySQL and PHP are perennially popular open-source companions for creating database-driven web sites. These guides cover MySQL, as well as its use with PHP and other languages. Web Database Applications goes beyond teaching particular functions to provide a general background in web database development, then describes how and why to use PHP and MySQL to accomplish the tasks described. Extensive appendixes cover the software's installment on multiple platforms, web protocols, a relational database case study, and other useful additions, while code samples are available online. Recommended for larger libraries. High Performance addresses intermediate to advanced users, walking them through ways to improve the reliability, scalability, and performance of larger MySQL applications. This nicely organized guide eschews how-to basics to address how MySQL works and provides real-world examples whenever possible. Explanations are clear and thorough, and the text supplies links to and explanations of several useful downloadable tools (some written by the authors). Highly recommended for medium and larger libraries. Complete Reference tries to be all things to all people, covering topics from an introduction to relational databases and installing and configuring MySQL to reference material for administrators, but is most appropriate for new and intermediate users. Sidebars and notes add info and link to additional resources, while a welcome thoroughness and clarity make this a good, basic purchase for all libraries. (c) Copyright 2010. Library Journals LLC, a wholly owned subsidiary of Media Source, Inc. No redistribution permitted. All rights reserved.

Table of Contents

Prefacep. ix
1. Database Applications and the Webp. 1
The Webp. 2
Three-Tier Architecturesp. 3
2. The PHP Scripting Languagep. 16
Introducing PHPp. 16
Conditions and Branchesp. 28
Loopsp. 33
Functionsp. 36
Working with Typesp. 37
User-Defined Functionsp. 43
A Working Examplep. 53
3. Arrays, Strings, and Advanced Data Manipulation in PHPp. 57
Arraysp. 57
Stringsp. 76
Regular Expressionsp. 87
Dates and Timesp. 97
Integers and Floatsp. 103
4. Introduction to Object-Oriented Programming with PHP 5p. 108
Classes and Objectsp. 108
Inheritancep. 124
Throwing and Catching Exceptionsp. 131
5. SQL and MySQLp. 134
Database Basicsp. 135
MySQL Command Interpreterp. 140
Managing Databases and Tablesp. 142
Inserting, Updating, and Deleting Datap. 148
Querying with SQL Selectp. 152
Join Queriesp. 160
Case Study: Adding a New Winep. 168
6. Querying Web Databasesp. 171
Querying a MySQL Database Using PHPp. 172
Processing User Inputp. 188
MySQL Function Referencep. 208
7. Pearp. 219
Overviewp. 219
Core Componentsp. 220
Packagesp. 230
8. Writing to Web Databasesp. 251
Database Inserts, Updates, and Deletesp. 251
Issues in Writing Data to Databasesp. 270
9. Validation with PHP and JavaScriptp. 285
Validation and Error Reporting Principlesp. 285
Server-Side Validation with PHPp. 287
JavaScript and Client-Side Validationp. 307
10. Sessionsp. 338
Introducing Session Managementp. 339
PHP Session Managementp. 340
Case Study: Using Sessions in Validationp. 347
When to Use Sessionsp. 357
PHP Session API and Configurationp. 360
11. Authentication and Securityp. 369
HTTP Authenticationp. 369
HTTP Authentication with PHPp. 373
Form-Based Authenticationp. 385
Protecting Data on the Webp. 397
12. Errors, Debugging, and Deploymentp. 402
Errorsp. 402
Common Programming Errorsp. 407
Custom Error Handlersp. 412
13. Reportingp. 422
Creating a Reportp. 422
Producing PDFp. 427
PDF-PHP Referencep. 440
14. Advanced Features of Object-Oriented Programming in PHP 5p. 457
Working with Class Hierarchiesp. 457
Class Type Hintsp. 462
Abstract Classes and Interfacesp. 462
Freight Calculator Examplep. 469
15. Advanced SQLp. 479
Exploring with SHOWp. 480
Advanced Queryingp. 481
Manipulating Data and Databasesp. 497
Functionsp. 505
Automating Queryingp. 513
Table Typesp. 516
Backup and Recoveryp. 522
Managing Users and Privilegesp. 527
Tuning MySQLp. 532
16. Hugh and Dave's Online Wines: A Case Studyp. 541
Functional and System Requirementsp. 542
Application Overviewp. 544
Common Componentsp. 551
17. Managing Customersp. 583
Code Overviewp. 584
Customer Validationp. 587
The Customer Formp. 591
18. The Shopping Cartp. 596
Code Overviewp. 597
The Winestore Home Pagep. 598
The Shopping Cart Implementationp. 604
19. Ordering and Shipping at the Online Winestorep. 618
Code Overviewp. 618
Credit Card and Shipping Instructionsp. 620
Finalizing Ordersp. 624
HTML and Email Receiptsp. 630
20. Searching and Authentication in the Online Winestorep. 642
Code Overviewp. 643
Searching and Browsingp. 648
Authenticationp. 658
A. Linux Installation Guidep. 667
B. Microsoft Windows Installation Guidep. 688
C. Mac OS X Installation Guidep. 698
D. Web Protocolsp. 714
E. Modeling and Designing Relational Databasesp. 726
F. Managing Sessions in the Database Tierp. 746
G. Resourcesp. 761
H. The Improved MySQL Libraryp. 766
Indexp. 779