PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites

Book description

"The expertise, thought, and effort that go into each book are obvious, and I sincerely appreciate your efforts. Keep up the wonderful work!"

--Tracey Moore (Memphis, TN)

Welcome to the only guidebook series that takes a visual approach to professional-level computer topics. Open the book and you will discover step-by-step screen shots that demonstrate over 140 key techniques using PHP amd MySQL, including:

  • Configuring Apache to process PHP code

  • Working with character strings

  • Creating, sorting, and comparing arrays

  • Defining and using functions

  • Finding and replacing substrings

  • Querying databases and retrieving data

  • Stopping and starting the MySQL server

  • Adding dynamic check boxes

  • Sending new Web pages to a browser

Extra / Apply It

  • High-resolution screen shots demonstrate each task

  • Succinct explanations walk you through step-by-step

  • Two-page lessons break big topics into bite-sized modules

  • "Apply It" and "Extra" sidebars highlight useful tips

Table of contents

  1. Copyright
  2. Praise For Visual Books ...
  3. Credits
  4. About the Author
  5. Author's Acknowledgments
  6. HOW TO USE THIS BOOK
    1. Who Needs This Book
    2. Book Organization
    3. What You Need to Use This Book
      1. Windows Requirements
      2. Mac Requirements
      3. Linux Requirements
    4. The Conventions in This Book
    5. What's on the Web Site
  7. 1. Setting Up Your Development Environment
    1. 1.1. Introducing Dynamic Web Sites
      1. 1.1.1. PHP
      2. 1.1.2. MySQL
      3. 1.1.3. How PHP and MySQL Work Together
      4. 1.1.4. Help for PHP and MySQL
      5. 1.1.5. PHP and MySQL Version
    2. 1.2. Set Up Your Development Environment
      1. 1.2.1. Design Your Development Environment
      2. 1.2.2. Select a Web Hosting Company
      3. 1.2.3. Register a Domain Name
      4. 1.2.4. Find Supporting Software
      5. 1.2.5. Run a Dynamic Web Site on Your Own Computer
    3. 1.3. Obtain Apache
      1. 1.3.1. Obtain Apache
    4. 1.4. Install Apache
      1. 1.4.1. Install Apache
    5. 1.5. Obtain MySQL
      1. 1.5.1. Obtain MySQL
    6. 1.6. Install MySQL
      1. 1.6.1. Install MySQL
    7. 1.7. Configure MySQL
      1. 1.7.1. Configure MySQL
    8. 1.8. Install MySQL Administration Programs
      1. 1.8.1. Install MySQL Administration Programs
        1. 1.8.1.1. DOWNLOAD AN ADMINISTRATION PROGRAM
        2. 1.8.1.2. INSTALL THE PROGRAM
    9. 1.9. Create MySQL Accounts for Use in PHP Scripts
      1. 1.9.1. Create MySQL Accounts for Use in PHP Scripts
    10. 1.10. Obtain PHP
      1. 1.10.1. Obtain PHP
    11. 1.11. Install PHP
      1. 1.11.1. Install PHP
    12. 1.12. Configure Apache to Process PHP Code
      1. 1.12.1. Configure Apache to Process PHP Code
    13. 1.13. Configure PHP
      1. 1.13.1. Configure PHP
    14. 1.14. Test Your Development Environment
      1. 1.14.1. Test Your Development Environment
  8. 2. Learning PHP Basics
    1. 2.1. How PHP Works
      1. 2.1.1. How the World Wide Web Works
      2. 2.1.2. Adding PHP Code to a Web Site
      3. 2.1.3. How the Web Server Processes PHP Files
    2. 2.2. Add PHP Code to a Web Page File
      1. 2.2.1. Add PHP Code to a Web Page File
    3. 2.3. Using PHP Statements
      1. 2.3.1. Using PHP Statements
    4. 2.4. Understanding PHP Output Statements
      1. 2.4.1. Understanding PHP Output Statements
    5. 2.5. Using PHP Variables
      1. 2.5.1. Using PHP Variables
    6. 2.6. Using PHP Constants
      1. 2.6.1. Using PHP Constants
    7. 2.7. Work with Numbers
      1. 2.7.1. Work with Numbers
    8. 2.8. Work with Character Strings
      1. 2.8.1. Work with Character Strings
    9. 2.9. Work with Dates and Times
      1. 2.9.1. Work with Dates and Times
    10. 2.10. Modify or Remove Variables
      1. 2.10.1. Modify or Remove Variables
    11. 2.11. Using Variable Variables
      1. 2.11.1. Using Variable Variables
    12. 2.12. Understanding Error Messages
      1. 2.12.1. Understanding Error Messages
    13. 2.13. Add Comments to a Script
      1. 2.13.1. Add Comments to a Script
  9. 3. Using Arrays
    1. 3.1. Create an Array
      1. 3.1.1. Create an Array
    2. 3.2. Modify or Remove an Array
      1. 3.2.1. Modify or Remove an Array
    3. 3.3. Get Information about an Array
      1. 3.3.1. Get Information about an Array
    4. 3.4. Sort an Array
      1. 3.4.1. Sort an Array
        1. 3.4.1.1. NUMERIC VERSUS STRING KEYS
        2. 3.4.1.2. SORTING BY VALUES VERSUS SORTING BY KEYS
    5. 3.5. Walk through an Array with foreach
      1. 3.5.1. Walk through an Array with foreach
    6. 3.6. Walk through an Array Manually
      1. 3.6.1. Walk through an Array Manually
    7. 3.7. Find Values in an Array
      1. 3.7.1. Find Values in an Array
    8. 3.8. Compare Arrays
      1. 3.8.1. Compare Arrays
    9. 3.9. Split and Merge Arrays
      1. 3.9.1. Split and Merge Arrays
    10. 3.10. Convert an Array into a String and Vice Versa
      1. 3.10.1. Convert an Array into a String and Vice Versa
    11. 3.11. Store a Set of Variables in an Array
      1. 3.11.1. Store a Set of Variables in an Array
    12. 3.12. Store Array Elements in Separate Variables
      1. 3.12.1. Store Array Elements in Separate Variables
    13. 3.13. Create a Multidimensional Array
      1. 3.13.1. Create a Multidimensional Array
        1. 3.13.1.1. CREATE ARRAYS
        2. 3.13.1.2. MODIFY AND REMOVE ARRAYS
    14. 3.14. Walk through a Multidimensional Array
      1. 3.14.1. Walk through a Multidimensional Array
    15. 3.15. Using Built-in PHP Arrays
      1. 3.15.1. PHP Arrays
      2. 3.15.2. Using PHP Arrays
      3. 3.15.3. Form Variables
      4. 3.15.4. $_SERVER and $_ENV
      5. 3.15.5. Built-in Arrays in Older PHP Versions
  10. 4. Controlling the Flow of the Script
    1. 4.1. Change the Order of Statement Execution
      1. 4.1.1. Conditional Statements
      2. 4.1.2. Loops
      3. 4.1.3. Conditions
      4. 4.1.4. Infinite Loops
    2. 4.2. Check the Contents of a Variable
      1. 4.2.1. Check the Contents of a Variable
    3. 4.3. Set up Conditions with Comparison Operators
      1. 4.3.1. Set Up Conditions with Comparison Operators
    4. 4.4. Introducing Regular Expressions
      1. 4.4.1. Special Characters
      2. 4.4.2. Building Regular Expressions
      3. 4.4.3. Using Regular Expressions
      4. 4.4.4. Types of Regular Expressions
    5. 4.5. Match Character Strings to Patterns Using Regular Expressions
      1. 4.5.1. Match Character Strings to Patterns Using Regular Expressions
    6. 4.6. Join Multiple Comparisons with Logical Operators
      1. 4.6.1. Join Multiple Comparisons with Logical Operators
    7. 4.7. Using an if Statement
      1. 4.7.1. Using an if Statement
    8. 4.8. Using a switch Statement
      1. 4.8.1. Using a switch Statement
    9. 4.9. Using a for Loop
      1. 4.9.1. Using a for Loop
        1. 4.9.1.1. CREATE A BASIC LOOP
        2. 4.9.1.2. USING MULTIPLE COUNTERS
    10. 4.10. Using a while Loop
      1. 4.10.1. Using a while Loop
    11. 4.11. Using a do-while Loop
      1. 4.11.1. Using a do-while Loop
    12. 4.12. Avoid an Infinite Loop
      1. 4.12.1. Avoid an Infinite Loop
    13. 4.13. Break Out of a Loop
      1. 4.13.1. Break Out of a Loop
        1. 4.13.1.1. BREAK VERSUS CONTINUE
        2. 4.13.1.2. BREAK OUT OF NESTED LOOPS
  11. 5. Reusing PHP Code
    1. 5.1. Include a Code File
      1. 5.1.1. Include a Code File
        1. 5.1.1.1. CREATE AN INCLUDE FILE
        2. 5.1.1.2. CREATE A SET OF INCLUDE FILES
        3. 5.1.1.3. CREATE THE SCRIPT
    2. 5.2. Configure the Path to the include Files
      1. 5.2.1. Configure the Path to the include Files
    3. 5.3. Include Files Automatically
      1. 5.3.1. Include Files Automatically
    4. 5.4. Store include Files Securely
      1. 5.4.1. Store include Files Securely
        1. 5.4.1.1. SET THE INCLUDE DIRECTORY
        2. 5.4.1.2. USE AN INCLUDE FILE
    5. 5.5. Define and Use a Function
      1. 5.5.1. Define and Use a Function
    6. 5.6. Using Variables in a Function
      1. 5.6.1. Using Variables in a Function
    7. 5.7. Pass Values to a Function
      1. 5.7.1. Pass Values to a Function
    8. 5.8. Return Values from a Function
      1. 5.8.1. Return Values from a Function
  12. 6. Some Useful PHP Built-In Functions
    1. 6.1. Format a Number
      1. 6.1.1. Format a Number
    2. 6.2. Round a Number
      1. 6.2.1. Round a Number
    3. 6.3. Find the Largest or Smallest Number
      1. 6.3.1. Find the Largest or Smallest Number
    4. 6.4. Remove Leading and Trailing Blank Spaces
      1. 6.4.1. Remove Leading and Trailing Blank Spaces
    5. 6.5. Change the Case of a String
      1. 6.5.1. Change the Case of a String
    6. 6.6. Format a String
      1. 6.6.1. Format a String
    7. 6.7. Count the Characters or Substrings in a String
      1. 6.7.1. Count the Characters or Substrings in a String
    8. 6.8. Locate a Substring in a String
      1. 6.8.1. Locate a Substring in a String
    9. 6.9. Get a Substring
      1. 6.9.1. Get a Substring
    10. 6.10. Find and Replace Substrings
      1. 6.10.1. Find and Replace Substrings
    11. 6.11. Add a Substring to a String
      1. 6.11.1. Add a Substring to a String
    12. 6.12. Using Regular Expressions to Replace Text
      1. 6.12.1. Using Regular Expressions to Replace Text
    13. 6.13. Pad or Repeat a String
      1. 6.13.1. Pad or Repeat a String
    14. 6.14. Convert a Character to and from an ASCII Value
      1. 6.14.1. Convert a Character to and from an ASCII Value
    15. 6.15. Compare Strings
      1. 6.15.1. Compare Strings
    16. 6.16. Convert a String into an Array
      1. 6.16.1. Convert a String into an Array
    17. 6.17. Send an Email Message
      1. 6.17.1. Send an Email Message
    18. 6.18. Send an HTTP Header
      1. 6.18.1. Send an HTTP Header
    19. 6.19. Read Configuration Settings
      1. 6.19.1. Read Configuration Settings
    20. 6.20. Set a Local PHP Configuration Option
      1. 6.20.1. Set a Local PHP Configuration Option
  13. 7. Using MySQL Databases
    1. 7.1. How a MySQL Database Works
      1. 7.1.1. Communicating with the MySQL Server
      2. 7.1.2. The Database Structure
      3. 7.1.3. The SQL Language
      4. 7.1.4. Sending a Query to the MySQL Server
      5. 7.1.5. Database Security
      6. 7.1.6. MySQL Versions
    2. 7.2. Send a Query with the mysql Client
      1. 7.2.1. Send a Query with the mysql Client
    3. 7.3. Send a Query with the MySQL Query Browser
      1. 7.3.1. Send a Query with the MySQL Query Browser
    4. 7.4. Create, Select, or Remove a MySQL Database
      1. 7.4.1. Create, Select, or Remove a MySQL Database
        1. 7.4.1.1. LIST THE DATABASES
        2. 7.4.1.2. CREATE AN ERROR
        3. 7.4.1.3. CREATE A DATABASE
        4. 7.4.1.4. SELECT A DATABASE
        5. 7.4.1.5. REMOVE A DATABASE
    5. 7.5. Define a MySQL Table
      1. 7.5.1. Table and Column Names
      2. 7.5.2. Data Types
      3. 7.5.3. The Primary Key
      4. 7.5.4. Auto-Increment Columns
      5. 7.5.5. Negative Numbers
      6. 7.5.6. Defaults
      7. 7.5.7. Empty Columns
      8. 7.5.8. Relationships between Tables
    6. 7.6. Create and Remove a MySQL Table
      1. 7.6.1. Create and Remove a MySQL Table
        1. 7.6.1.1. CREATE A TABLE
        2. 7.6.1.2. REMOVE A TABLE
    7. 7.7. Modify the MySQL Table Structure
      1. 7.7.1. Modify the MySQL Table Structure
    8. 7.8. Add a Row of Data to a Database
      1. 7.8.1. Add a Row of Data to a Database
    9. 7.9. Add Data from a Text File to a Database
      1. 7.9.1. Add Data from a Text File to a Database
    10. 7.10. Store Incremental Values in a Column
      1. 7.10.1. Store Incremental Values in a Column
    11. 7.11. Retrieve Data from a Database
      1. 7.11.1. Retrieve Data from a Database
    12. 7.12. Limit Query Execution to Specific Rows with a WHERE Clause
      1. 7.12.1. Limit Query Execution to Specific Rows with a WHERE Clause
    13. 7.13. Retrieve Data from Multiple Tables with UNION
      1. 7.13.1. Retrieve Data from Multiple Tables with UNION
    14. 7.14. Retrieve Data from Multiple Tables by Joining Tables
      1. 7.14.1. Retrieve Data from Multiple Tables by Joining Tables
    15. 7.15. Update Data in a Database
      1. 7.15.1. Update Data in a Database
    16. 7.16. Remove Data from a Database
      1. 7.16.1. Remove Data from a Database
    17. 7.17. Query a MySQL Database from a PHP Script
      1. 7.17.1. Query a MySQL Database from a PHP Script
    18. 7.18. Display Database Data on a Web Page in a PHP Script
      1. 7.18.1. Display Database Data on a Web Page in a PHP Script
    19. 7.19. Handle MySQL Errors
      1. 7.19.1. Handle MySQL Errors
  14. 8. Administering MySQL Databases
    1. 8.1. Understanding MySQL Accounts
      1. 8.1.1. The Account Name and Host
      2. 8.1.2. Passwords
      3. 8.1.3. Account Privileges
      4. 8.1.4. The Account Information Database
      5. 8.1.5. Default Accounts
      6. 8.1.6. Managing Databases
      7. 8.1.7. The Access Process
    2. 8.2. View Existing Accounts
      1. 8.2.1. View Existing Accounts
        1. 8.2.1.1. USING SQL QUERIES
        2. 8.2.1.2. USING MYSQL ADMINISTRATOR
    3. 8.3. Create a MySQL Account
      1. 8.3.1. Create a MySQL Account
    4. 8.4. Change the Password of a MySQL Account
      1. 8.4.1. Change the Password of a MySQL Account
    5. 8.5. Add and Remove Privileges
      1. 8.5.1. Add and Remove Privileges
        1. 8.5.1.1. ADD PRIVILEGES
        2. 8.5.1.2. REMOVE PRIVILEGES
    6. 8.6. Change the Name of a MySQL Account
      1. 8.6.1. Change the Name of a MySQL Account
    7. 8.7. Remove a MySQL Account
      1. 8.7.1. Remove a MySQL Account
    8. 8.8. Stop and Start the MySQL Server
      1. 8.8.1. Stop and Start the MySQL Server
    9. 8.9. Using MySQL Logs
      1. 8.9.1. Using MySQL Logs
    10. 8.10. Back Up Data
      1. 8.10.1. Back Up Data
    11. 8.11. Restore Data
      1. 8.11.1. Restore Data
    12. 8.12. Upgrade MySQL
      1. 8.12.1. Skipping Versions
      2. 8.12.2. Previous Versions
      3. 8.12.3. Changes to Tables
      4. 8.12.4. Types of Tables
      5. 8.12.5. Change Documentation
  15. 9. Adding HTML forms to a Web Page
    1. 9.1. Display an HTML Form
      1. 9.1.1. Display an HTML Form
    2. 9.2. Add a Text Field
      1. 9.2.1. Add a Text Field
    3. 9.3. Add a Multiline Text Area
      1. 9.3.1. Add a Multiline Text Area
    4. 9.4. Add a Hidden Field
      1. 9.4.1. Add a Hidden Field
    5. 9.5. Add a Dynamic Selection List to a Form
      1. 9.5.1. Add a Dynamic Selection List to a Form
    6. 9.6. Add a Date Selection List
      1. 9.6.1. Add a Date Selection List
    7. 9.7. Add Dynamic Radio Buttons
      1. 9.7.1. Add Dynamic Radio Buttons
    8. 9.8. Add Dynamic Check Boxes
      1. 9.8.1. Add Dynamic Check Boxes
    9. 9.9. Create One or More Submit Buttons
      1. 9.9.1. Create One or More Submit Buttons
    10. 9.10. Choose the POST or GET Method for a Form
      1. 9.10.1. Choose the POST or GET Method for a Form
        1. 9.10.1.1. THE POST METHOD
        2. 9.10.1.2. THE GET METHOD
    11. 9.11. Create a Form That Uploads a File
      1. 9.11.1. Create a Form That Uploads a File
  16. 10. Processing Data from Forms
    1. 10.1. Process Information from a Form
      1. 10.1.1. The Superglobal Arrays
      2. 10.1.2. The Long Built-in Arrays
      3. 10.1.3. Converting the Arrays to Variables
      4. 10.1.4. Checking Form Information
      5. 10.1.5. Trimming the Data
      6. 10.1.6. Handling HTML Tags in Form Fields
    2. 10.2. Display Data from a Form
      1. 10.2.1. Display Data from a Form
    3. 10.3. Display and Process a Form in One Script
      1. 10.3.1. Display and Process a Form in One Script
    4. 10.4. Check for Blank Fields
      1. 10.4.1. Check for Blank Fields
    5. 10.5. Verify Form Data
      1. 10.5.1. Verify Form Data
    6. 10.6. Clean Form Data
      1. 10.6.1. Clean Form Data
    7. 10.7. Add Form Data to a Database
      1. 10.7.1. Building a Query
      2. 10.7.2. Protecting against SQL Injection
      3. 10.7.3. SQL Injection
      4. 10.7.4. Automatic Escaping (Magic Quotes)
      5. 10.7.5. Escaping Form Data with PHP Functions
    8. 10.8. Insert Form Data into a Database
      1. 10.8.1. Insert Form Data into a Database
    9. 10.9. Update or Remove Database Data
      1. 10.9.1. Update or Remove Database Data
    10. 10.10. Process an Uploaded File
      1. 10.10.1. Process an Uploaded File
  17. 11. Managing User Sessions
    1. 11.1. Understanding User Sessions
      1. 11.1.1. Moving from One Web Page to the Next
      2. 11.1.2. Statelessness
    2. 11.2. Send a New Web Page to the Browser
      1. 11.2.1. Send a New Web Page to the Browser
    3. 11.3. Add Information to a URL
      1. 11.3.1. Add Information to a URL
    4. 11.4. Store Information in Cookies
      1. 11.4.1. Store Information in Cookies
    5. 11.5. Store Information in a PHP Session
      1. 11.5.1. Store Information in a PHP Session
    6. 11.6. Using PHP Sessions without Cookies
      1. 11.6.1. Using PHP Sessions without Cookies
        1. 11.6.1.1. WITH TRANS_SID TURNED ON
        2. 11.6.1.2. WITH TRANS_SID TURNED OFF
        3. 11.6.1.3. ACCESS THE SESSION VARIABLE
  18. 12. Object-Oriented Programming in PHP
    1. 12.1. Understanding Object-Oriented Programming
      1. 12.1.1. Object-Oriented Programming
      2. 12.1.2. Objects
      3. 12.1.3. Classes
      4. 12.1.4. Properties
      5. 12.1.5. Methods
      6. 12.1.6. Abstraction
      7. 12.1.7. Constructor
      8. 12.1.8. Inheritance
      9. 12.1.9. Exceptions
    2. 12.2. Create and Use an Object
      1. 12.2.1. Create and Use an Object
    3. 12.3. Set Properties in a Class
      1. 12.3.1. Set Properties in a Class
    4. 12.4. Add Methods to a Class
      1. 12.4.1. Add Methods to a Class
    5. 12.5. Write a Constructor or a Destructor Method
      1. 12.5.1. Write a Constructor or a Destructor Method
    6. 12.6. Using PHP Magic Methods to Get or Set Properties
      1. 12.6.1. Using PHP Magic Methods to Get or Set Properties
    7. 12.7. Using Inheritance in a Class
      1. 12.7.1. Using Inheritance in a Class
    8. 12.8. Using Exceptions
      1. 12.8.1. Using Exceptions
    9. 12.9. Copy and Compare Objects
      1. 12.9.1. Copy and Compare Objects
    10. 12.10. Get Information about Objects and Classes
      1. 12.10.1. Get Information about Objects and Classes
    11. 12.11. Using Abstract Classes
      1. 12.11.1. Using Abstract Classes
    12. 12.12. Using Interfaces
      1. 12.12.1. Using Interfaces
  19. A. Programming Editors and IDEs for PHP
    1. A.1. Programming Editors
    2. A.2. Integrated Development Environments
  20. B. Troubleshooting Tips
    1. B.1. Understanding Error Messages
    2. B.2. Common Errors

Product information

  • Title: PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites
  • Author(s): Janet Valade
  • Release date: September 2006
  • Publisher(s): Visual
  • ISBN: 9780470048399