You are previewing Beginning PHP and MySQL: From Novice to Professional, Third Edition.
O'Reilly logo
Beginning PHP and MySQL: From Novice to Professional, Third Edition

Book Description

Beginning PHP and MySQL: From Novice to Professional, Third Edition offers a comprehensive introduction to two of the most prominent open-source technologies on the planet: the PHP scripting language and the MySQL database server. Updated to introduce the features found in MySQL's most significant release to date, readers will learn how to take advantage of the features of both technologies to build powerful, manageable, and stable web applications.

Essentially three books in one, readers will not only profit from extensive introductions to the core features of each technology, but also learn how to effectively integrate the two in order to build robust data-driven applications. Packed with practical examples and insight into the real-world challenges faced by developers based on author W. Jason Gilmore's seven years of expertise working with these technologies, readers will repeatedly return to this book as both a valuable instructional tool and reference guide.

What you'll learn

  • The PHP language

  • How to back your web site with MySQL

  • Templating so that you can apply a consistent design across all pages on your site

  • How to authenticate your web site users

  • How to use cookies to maintain information (such as items in a shopping cart) while a user is browsing your site

Who this book is for

This book is written for developers seeking to take advantage of the PHP language and MySQL database to create powerful web applications.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewers
  7. Acknowledgments
  8. Introduction
    1. Download the Code
    2. Contact Me!
  9. CHAPTER 1: Introducing PHP
    1. History
    2. General Language Features
    3. Summary
  10. CHAPTER 2: Configuring Your Environment
    1. Installation Prerequisites
    2. Installing Apache and PHP on Linux
    3. Installing Apache and PHP on Windows
    4. Installing IIS and PHP on Windows
    5. Testing Your Installation
    6. Configuring PHP
    7. Run-Time Configuration
    8. Choosing a Code Editor
    9. Choosing a Web Hosting Provider
    10. Summary
  11. CHAPTER 3: PHP Basics
    1. Embedding PHP Code in Your Web Pages
    2. Commenting Your Code
    3. Outputting Data to the Browser
    4. PHP's Supported Datatypes
    5. Identifiers
    6. Variables
    7. Constants
    8. Expressions
    9. String Interpolation
    10. Control Structures
    11. Summary
  12. CHAPTER 4: Functions
    1. Invoking a Function
    2. Creating a Function
    3. Function Libraries
    4. Summary
  13. CHAPTER 5: Arrays
    1. What Is an Array?
    2. Creating an Array
    3. Adding and Removing Array Elements
    4. Locating Array Elements
    5. Traversing Arrays
    6. Determining Array Size and Uniqueness
    7. Sorting Arrays
    8. Merging, Slicing, Splicing, and Dissecting Arrays
    9. Other Useful Array Functions
    10. Summary
  14. CHAPTER 6: Object-Oriented PHP
    1. The Benefits of OOP
    2. Key OOP Concepts
    3. Constructors and Destructors
    4. Static Class Members
    5. The instanceof Keyword
    6. Helper Functions
    7. Autoloading Objects
    8. Summary
  15. CHAPTER 7: Advanced OOP Features
    1. Advanced OOP Features Not Supported by PHP
    2. Object Cloning
    3. Inheritance
    4. Interfaces
    5. Abstract Classes
    6. Introducing Namespaces
    7. Summary
  16. CHAPTER 8: Error and Exception Handling
    1. Configuration Directives
    2. Error Logging
    3. Exception Handling
    4. Summary
  17. CHAPTER 9: Strings and Regular Expressions
    1. Regular Expressions
    2. Other String-Specific Functions
    3. Alternatives for Regular Expression Functions
    4. Taking Advantage of PEAR: Validate_US
    5. Summary
  18. CHAPTER 10: Working with the File and Operating System
    1. Learning About Files and Directories
    2. Working with Files
    3. Executing Shell Commands
    4. System-Level Program Execution
    5. Summary
  19. CHAPTER 11: PEAR
    1. Popular PEAR Packages
    2. The Power of PEAR: Converting Numeral Formats
    3. Installing and Updating PEAR
    4. Using the PEAR Package Manager
    5. Summary
  20. CHAPTER 12: Date and Time
    1. The Unix Timestamp
    2. PHP's Date and Time Library
    3. Date Fu
    4. Date and Time Enhancements for PHP 5.1+ Users
    5. Summary
  21. CHAPTER 13: Forms
    1. PHP and Web Forms
    2. Taking Advantage of PEAR: HTML_QuickForm
    3. Summary
  22. CHAPTER 14: Authenticating Your Users
    1. HTTP Authentication Concepts
    2. PHP Authentication
    3. PHP Authentication Methodologies
    4. User Login Administration
    5. Summary
  23. CHAPTER 15: Handling File Uploads
    1. Uploading Files via HTTP
    2. Uploading Files with PHP
    3. Taking Advantage of PEAR: HTTP_Upload
    4. Summary
  24. CHAPTER 16: Networking
    1. DNS, Services, and Servers
    2. Mail
    3. Common Networking Tasks
    4. Summary
  25. CHAPTER 17: PHP and LDAP
    1. Using LDAP from PHP
    2. Summary
  26. CHAPTER 18: Session Handlers
    1. What Is Session Handling?
    2. Configuration Directives
    3. Working with Sessions
    4. Practical Session-Handling Examples
    5. Creating Custom Session Handlers
    6. Summary
  27. CHAPTER 19: Templating with Smarty
    1. What's a Templating Engine?
    2. Introducing Smarty
    3. Installing Smarty
    4. Using Smarty
    5. Smarty's Presentational Logic
    6. Creating Configuration Files
    7. Using CSS in Conjunction with Smarty
    8. Caching
    9. Summary
  28. CHAPTER 20: Web Services
    1. Why Web Services?
    2. Really Simple Syndication
    3. SimpleXML
    4. SOAP
    5. Summary
  29. CHAPTER 21: Secure PHP Programming
    1. Configuring PHP Securely
    2. Hiding Configuration Details
    3. Hiding Sensitive Data
    4. Sanitizing User Data
    5. Data Encryption
    6. Summary
  30. CHAPTER 22: SQLite
    1. Introduction to SQLite
    2. PHP's SQLite Library
    3. Summary
  31. CHAPTER 23: Building Web Sites for the World
    1. Translating Web Sites with Gettext
    2. Localizing Dates, Numbers, and Times
    3. Summary
  32. CHAPTER 24: MVC and the Zend Framework
    1. Introducing MVC
    2. PHP's Framework Solutions
    3. Introducing the Zend Framework
    4. Summary
  33. CHAPTER 25: Introducing MySQL
    1. What Makes MySQL So Popular?
    2. The Evolution of MySQL
    3. Prominent MySQL Users
    4. Summary
  34. CHAPTER 26: Installing and Configuring MySQL
    1. Downloading MySQL
    2. Installing MySQL
    3. Setting the MySQL Administrator Password
    4. Starting and Stopping MySQL
    5. Configuring and Optimizing MySQL
    6. Configuring PHP to Work with MySQL
    7. Summary
  35. CHAPTER 27: The Many MySQL Clients
    1. Introducing the Command-Line Clients
    2. MySQL's GUI Client Programs
    3. phpMyAdmin
    4. Summary
  36. CHAPTER 28: MySQL Storage Engines and Datatypes
    1. Storage Engines
    2. Datatypes and Attributes
    3. Working with Databases and Tables
    4. Summary
  37. CHAPTER 29: Securing MySQL
    1. What You Should Do First
    2. Securing the mysqld Daemon
    3. The MySQL Access Privilege System
    4. User and Privilege Management
    5. Limiting User Resources
    6. Secure MySQL Connections
    7. Summary
  38. CHAPTER 30: Using PHP with MySQL
    1. Handling Installation Prerequisites
    2. Using the mysqli Extension
    3. Interacting with the Database
    4. Executing Database Transactions
    5. Summary
  39. CHAPTER 31: Introducing PDO
    1. Another Database Abstraction Layer?
    2. Using PDO
    3. Summary
  40. CHAPTER 32: Stored Routines
    1. Should You Use Stored Routines?
    2. How MySQL Implements Stored Routines
    3. Integrating Routines into Web Applications
    4. Summary
  41. CHAPTER 33: MySQL Triggers
    1. Introducing Triggers
    2. MySQL's Trigger Support
    3. Integrating Triggers into Web Applications
    4. Summary
  42. CHAPTER 34: MySQL Views
    1. Introducing Views
    2. MySQL's View Support
    3. Incorporating Views into Web Applications
    4. Summary
  43. CHAPTER 35: Practical Database Queries
    1. Sample Data
    2. Creating Tabular Output with PEAR
    3. Sorting Output
    4. Creating Paged Output
    5. Listing Page Numbers
    6. Querying Multiple Tables with Subqueries
    7. Iterating Result Sets with Cursors
    8. Summary
  44. CHAPTER 36: Indexes and Searching
    1. Database Indexing
    2. Forms-Based Searches
    3. Summary
  45. CHAPTER 37: Transactions
    1. What's a Transaction?
    2. MySQL's Transactional Capabilities
    3. A Sample Project
    4. Building Transactional Applications with PHP
    5. Summary
  46. CHAPTER 38: Importing and Exporting Data
    1. Sample Table
    2. Using Data Delimitation
    3. Importing Data
    4. Exporting Data
    5. Summary
  47. Index