1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP5 and MySQL Bible potx

1.1K 2.1K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • PHP5 and MySQL Bible (Bible)

    • Cover

  • Preface

  • Acknowledgments

  • Contents

  • Part I: PHP: The Basics

    • Chapter 1: Why PHP and MySQL?

      • What Is PHP?

      • What Is MySQL?

      • The History of PHP

      • The History of MySQL

      • Reasons to Love PHP and MySQL

        • Cost

        • Ease of Use

        • HTML-embeddedness

        • Cross-platform compatibility

        • Not tag-based

        • Stability

        • Speed

        • Open source licensing

        • Many extensions

        • Fast feature development

        • Popularity

        • Not proprietary

        • Strong user communities

      • Summary

    • Chapter 2: Server-Side Web Scripting

      • Static HTML

      • Client-Side Technologies

      • Server-Side Scripting

      • What Is Server-Side Scripting Good for?

      • Summary

    • Chapter 3: Getting Started with PHP

      • Hosting versus DIY

        • The ISP option

        • The self-hosting option: Pros and cons

        • Compromise solutions

      • Installing PHP

        • Before you can begin

        • Installation procedures

        • Development tools

      • Summary

    • Chapter 4: Adding PHP to HTML

      • Your HTML Is Already PHP-Compliant!

      • Escaping from HTML

        • Canonical PHP tags

        • Short-open (SGML-style) tags

        • Hello World

        • Jumping in and out of PHP mode

        • Including files

      • Summary

    • Chapter 5: Syntax and Variables

      • PHP Is Forgiving

      • HTML Is Not PHP

      • PHP's Syntax Is C-Like

        • PHP is whitespace insensitive

        • PHP is sometimes case sensitive

        • Statements are expressions terminated by semicolons

        • Braces make blocks

      • Comments

        • C-style multiline comments

        • Single-line comments: # and //

      • Variables

        • PHP variables are Perl-like

        • Declaring variables (or not)

        • Assigning variables

        • Reassigning variables

        • Unassigned variables

        • Variable scope

        • You can switch modes if you want

        • Constants

      • Types in PHP: Don't Worry, Be Happy

        • No variable type declarations

        • Automatic type conversion

        • Types assigned by context

      • Type Summary

      • The Simple Types

        • Integers

        • Doubles

        • Booleans

        • NULL

        • Strings

      • Output

        • Echo and print

        • Variables and strings

      • Summary

    • Chapter 6: Control and Functions

      • Boolean Expressions

        • Boolean constants

        • Logical operators

        • Comparison operators

        • The ternary operator

      • Branching

        • If-else

        • Switch

      • Looping

        • Bounded loops versus unbounded loops

        • While

        • Do-while

        • For

        • Looping examples

        • Break and continue

        • A note on infinite loops

      • Alternate Control Syntaxes

      • Terminating Execution

      • Using Functions

        • Return values versus side effects

      • Function Documentation

        • Headers in documentation

        • Finding function documentation

      • Defining Your Own Functions

        • What is a function?

        • Function definition syntax

        • Function definition example

        • Formal parameters versus actual parameters

        • Argument number mismatches

      • Functions and Variable Scope

        • Global versus local

        • Static variables

        • Exceptions

      • Function Scope

        • Include and require

        • Recursion

      • Summary

    • Chapter 7: Passing Information between Pages

      • HTTP Is Stateless

      • GET Arguments

      • A Better Use for GET-Style URLs

      • POST Arguments

      • Formatting Form Variables

        • Consolidating forms and form handlers

        • Using array variables with forms

      • PHP Superglobal Arrays

      • Extended Example: An Exercise Calculator

      • Summary

    • Chapter 8: Strings

      • Strings in PHP

        • Interpolation with curly braces

        • Characters and string indexes

        • String operators

        • Concatenation and assignment

        • The heredoc syntax

      • String Functions

        • Inspecting strings

        • Finding characters and substrings

        • Comparison and searching

        • Searching

        • Substring selection

        • String cleanup functions

        • String replacement

        • Case functions

        • Escaping functions

        • Printing and output

      • Extended Example: An Exercise Calculator

      • Summary

    • Chapter 9: Arrays and Array Functions

      • The Uses of Arrays

      • What Are PHP Arrays?

      • Creating Arrays

        • Direct assignment

        • The array( ) construct

        • Specifying indices using array( )

        • Functions returning arrays

      • Retrieving Values

        • Retrieving by index

        • The list( ) construct

      • Multidimensional Arrays

      • Inspecting Arrays

      • Deleting from Arrays

      • Iteration

        • Support for iteration

        • Using iteration functions

        • Our favorite iteration method: foreach

        • Iterating with current( ) and next( )

        • Starting over with reset( )

        • Reverse order with end( ) and prev( )

        • Extracting keys with key( )

        • Empty values and the each( ) function

        • Walking with array_walk( )

      • Extended Example: An Exercise Calculator

      • Summary

    • Chapter 10: Numbers

      • Numerical Types

      • Mathematical Operators

        • Arithmetic operators

        • Arithmetic operators and types

        • Incrementing operators

        • Assignment operators

        • Comparison operators

        • Precedence and parentheses

      • Simple Mathematical Functions

      • Randomness

        • Seeding the generator

        • Example: Making a random selection

      • Extended Example: An Exercise Calculator

      • Summary

    • Chapter 11: Basic PHP Gotchas

      • Installation-Related Problems

        • Symptom: Text of file displayed in browser window

        • Symptom: PHP blocks showing up as text under HTTP or browser prompts you to save file

        • Symptom: Server or host not found/Page cannot be displayed

      • Rendering Problems

        • Symptom: Totally blank page

        • Symptom: Document contains no data

        • Symptom: Incomplete or unintended page

        • Symptom: PHP code showing up in Web browser

      • Failures to Load Page

        • Symptom: Page cannot be found

        • Symptom: Failed opening [file] for inclusion

      • Parse Errors

        • Symptom: Parse error message

        • The missing semicolon

        • No dollar signs

        • Mode issues

        • Unescaped quotes

        • Unterminated strings

        • Other parse error causes

      • File Permissions

        • Symptom: HTTP error 403

      • Missing Includes

        • Symptom: Include warning

      • Unbound Variables

        • Symptom: Variable not showing up in print string

        • Symptom: Numerical variable unexpectedly zero

        • Causes of unbound variables

      • Overwritten Variables

        • Symptom: The variable has a valid value, just not the one you expected

      • Function Problems

        • Symptom: Call to undefined function my_function( )

        • Symptom: Call to undefined function ( )

        • Symptom: Call to undefined function array( )

        • Symptom: Cannot redeclare my_function( )

        • Symptom: Wrong parameter count

      • Math Problems

        • Symptom: Division-by-zero warning

        • Symptom: Unexpected arithmetic result

        • Symptom: NaN (or NAN)

      • Time-outs

      • Summary

  • Part II: PHP and MySQL

    • Chapter 12: Choosing a Database for PHP

      • What Is a Database?

      • Why a Database?

        • Maintainability and scalability

        • Portability

        • Avoiding awkward programming

        • Searching

        • Security

        • N-tier architecture

        • Potential downside: Performance

      • Choosing a Database

        • You may not have a choice

        • Flat-file, relational, object-relational

        • ODBC/JDBC versus native API

        • Swappable databases

      • Advanced Features to Look For

        • A GUI

        • Subquery

        • SELECT INTO

        • Complex joins

        • Threading and locking

        • Transactional databases

        • Procedures and triggers

        • Indexes

        • Foreign keys and integrity constraints

        • Database replication

      • PHP-Supported Databases

      • Database Abstraction (or Not)

      • Our Focus: MySQL

      • Summary

    • Chapter 13: SQL Tutorial

      • Relational Databases and SQL

      • SQL Standards

      • The Workhorses of SQL

        • SELECT

        • INSERT

        • UPDATE

        • DELETE

      • Database Design

      • Privileges and Security

        • Setting database permissions

        • Keep database passwords outside the Web tree

        • Use two layers of password protection

        • Learn to make backups

      • Summary

    • Chapter 14: MySQL Database Administration

      • MySQL Licensing

      • Installing MySQL: Moving to Version 4

        • Preinstall considerations

        • Downloading MySQL

        • Installing MySQL on Windows

        • Installing MySQL on Unix

        • Installing MySQL on Mac OS X

        • Post-installation housekeeping

        • Basic MySQL client commands

      • MySQL User Administration

        • Local development

        • Standalone Web site

        • Shared-hosting Web site

      • PHPMyAdmin

      • Backups

      • Replication

      • Recovery

        • myisamchk

        • mysqlcheck

      • Summary

    • Chapter 15: PHP/MySQL Functions

      • Connecting to MySQL

      • Making MySQL Queries

      • Fetching Data Sets

      • Getting Data about Data

      • Multiple Connections

      • Building in Error Checking

      • Creating MySQL Databases with PHP

        • MySQL data types

      • MySQL Functions

      • Summary

    • Chapter 16: Displaying Queries in Tables

      • HTML Tables and Database Tables

        • One-to-one mapping

        • Example: A single-table displayer

        • The sample tables

        • Improving the displayer

      • Complex Mappings

        • Multiple queries versus complex printing

        • A multiple-query example

        • A complex printing example

      • Creating the Sample Tables

      • Summary

    • Chapter 17: Building Forms from Queries

      • HTML Forms

      • Basic Form Submission to a Database

      • Self-Submission

      • Editing Data with an HTML Form

        • TEXT and TEXTAREA

        • CHECKBOX

        • RADIO

        • SELECT

      • Summary

    • Chapter 18: PHP/MySQL Efficiency

      • Connections-Reduce, Reuse, Recycle

        • A bad example: One connection per statement

        • Multiple results don't need multiple connections

        • Persistent connections

      • Indexing and Table Design

        • Indexing

        • Everything including the kitchen sink

        • Other types of indexes

        • Table design

      • Making the Database Work for You

        • It's probably faster than you are

        • A bad example: Looping, not restricting

        • Creating date and time fields

        • Finding the last inserted row

      • Summary

    • Chapter 19: PHP/MySQL Gotchas

      • No Connection

      • Problems with Privileges

      • Unescaped Quotes

      • Broken SQL Statements

        • Misspelled names

        • Comma faults

        • Unquoted string arguments

        • Unbound variables

      • Too Little Data, Too Much Data

      • Specific SQL Functions

        • mysql_affected_rows( ) versus mysql_num_rows( )

        • mysql_result( )

        • OCIFetch( )

      • Debugging and Sanity Checking

      • Summary

  • Part III: Advanced Features and Techniques

    • Chapter 20: Object-Oriented Programming with PHP

      • What Is Object-Oriented Programming?

        • The simple idea

        • Elaboration: Objects as datatypes

        • Elaboration: Inheritance

        • Elaboration: Encapsulation

        • Elaboration: Constructors and destructors

        • Terminology

      • Basic PHP Constructs for OOP

        • Defining classes

        • Accessing member variables

        • Creating instances

        • Constructor functions

        • Inheritance

        • Overriding functions

        • Chained subclassing

        • Modifying and assigning objects

        • Scoping issues

      • Advanced OOP Features

        • Public, Private, and Protected Members

        • Interfaces

        • Constants

        • Abstract Classes

        • Simulating class functions

        • Calling parent functions

        • Automatic calls to parent constructors

        • Simulating method overloading

        • Serialization

      • Introspection Functions

        • Function overview

        • Example: Class genealogy

        • Example: Matching variables and DB columns

        • Example: Generalized test methods

      • Extended Example: HTML Forms

      • Gotchas and Troubleshooting

        • Symptom: Member variable has no value in member function

        • Symptom: Parse error, expecting T_VARIABLE ..

      • OOP Style in PHP

        • Naming conventions

        • Accessor functions

        • Designing for inheritance

      • Summary

    • Chapter 21: Advanced Array Functions

      • Transformations of Arrays

        • Retrieving keys and values

        • Flipping, reversing, and shuffling

        • Merging, padding, slicing, and splicing

      • Stacks and Queues

      • Translating between Variables and Arrays

      • Sorting

      • Printing Functions for Visualizing Arrays

      • Summary

    • Chapter 22: String and Regular Expression Functions

      • Tokenizing and Parsing Functions

      • Why Regular Expressions?

        • Regex in PHP

        • An example of POSIX-style regex

        • Regular expression functions

      • Perl-Compatible Regular Expressions

      • Example: A Simple Link-Scraper

        • The regular expression

        • Using the expression in a function

      • Advanced String Functions

        • HTML functions

        • Hashing using MD5

        • Strings as character collections

        • String similarity functions

      • Summary

    • Chapter 23: Filesystem and System Functions

      • Understanding PHP File Permissions

      • File Reading and Writing Functions

        • File open

        • File read

        • Constructing file downloads by using fpassthru( )

        • File write

        • File close

      • Filesystem and Directory Functions

        • feof

        • file_exists

        • filesize

      • Network Functions

        • Syslog functions

        • DNS functions

        • Socket functions

      • Date and Time Functions

        • If you don't know either date or time

        • If you've already determined the date/time/timestamp

      • Calendar Conversion Functions

      • Summary

    • Chapter 24: Sessions, Cookies, and HTTP

      • What's a Session?

        • So what's the problem?

        • Why should you care?

      • Home-Grown Alternatives

        • IP address

        • Hidden variables

        • Cookie-based homegrown sessions

      • How Sessions Work in PHP

        • Making PHP aware of your session

        • Propagating session variables

        • Where is the data really stored?

      • Sample Session Code

      • Session Functions

      • Configuration Issues

      • Cookies

        • The setcookie( ) function

        • Examples

        • Deleting cookies

        • Reading cookies

        • register_globals and variable overwriting

        • Cookie pitfalls

      • Sending HTTP Headers

        • Example: Redirection

        • Example: HTTP authentication

        • Header gotchas

      • Gotchas and Troubleshooting

      • Summary

    • Chapter 25: Types and Type Conversions

      • Type Round-up

      • Resources

        • What are resources?

        • How to handle resources

      • Type Testing

      • Assignment and Coercion

        • Integer overflow

        • Finding the largest integer

      • Summary

    • Chapter 26: Advanced Use of Functions

      • Variable Numbers of Arguments

        • Default arguments

        • Arrays as multiple-argument substitutes

        • Multiple arguments in PHP4 and above

      • Call-by-Value

      • Call-by-Reference

      • Variable Function Names

      • An Extended Example

      • Summary

    • Chapter 27: Mathematics

      • Mathematical Constants

      • Tests on Numbers

      • Base Conversion

      • Exponents and Logarithms

      • Trigonometry

      • Arbitrary Precision (BC)

        • An arbitrary-precision example

        • Converting code to arbitrary-precision

      • Summary

    • Chapter 28: PEAR

      • What Is PEAR?

      • The PEAR Package System

        • A sampling of PEAR packages

        • How the PEAR database works

        • The Package Manager

        • Using the Manager

      • PHP Foundation Classes (PFC)

      • PHP Extension Code Library (PECL)

      • The PEAR Coding Style

        • Indenting, whitespace, and line length

        • Formatting control structures

        • Formatting functions and function calls

      • Summary

    • Chapter 29: Security

      • Possible Attacks

        • Site defacement

        • Accessing source code

        • Reading arbitrary files

        • Running arbitrary programs

        • Viruses and other e-critters

        • E-mail safety

      • Register Globals

      • File Uploads

      • Encryption

        • Public-key encryption

        • Single-key encryption

        • Encrypting cookies

        • Hashing

        • Digitally signing files

        • Secure Sockets Layer

      • FYI: Security Web Sites

      • Summary

    • Chapter 30: Configuration

      • Viewing Environment Variables

      • Understanding PHP Configuration

        • Compile-time options

        • CGI compile-time options

        • Apache configuration files

        • The php.ini file

      • Improving PHP Performance

      • Summary

    • Chapter 31: Exceptions and Error Handling

      • Error Handling in PHP5

        • Errors and exceptions

        • The Exception class

        • The try/catch block

        • Throwing an exception

        • Defining your own Exception subclasses

        • Limitations of Exceptions in PHP

      • Other Methods of Error Handling

        • Native PHP errors

        • Defining an error handler

        • Triggering a user error

      • Logging and Debugging

      • Summary

    • Chapter 32: Debugging

      • General Troubleshooting Strategies

        • Change one thing at a time

        • Try to isolate the problem

        • Simplify, then build up

        • Check the obvious

        • Document your solution

        • After fixing, re-test

      • A Menagerie of Bugs

        • Compile-time bugs

        • Run-time bugs

        • Logical bugs

      • Using Web Server Logs

        • Apache

        • IIS

      • PHP Error Reporting and Logging

        • Error reporting

        • Error logging

        • Choosing which errors to report or log

      • Error-Reporting Functions

        • Diagnostic print statements

        • Using print_r( )

        • Using syslog( )

        • Logging to a custom location

        • Using error_log( )

      • Visual Debugging Tools

        • Avoiding errors in the first place

        • Finding errors when they occur

      • Summary

    • Chapter 33: Style

      • The Uses of Style

      • Readability

        • Comments

        • PHPDoc

        • File and variable names

        • Uniformity of style

      • Maintainability

        • Avoid magic numbers

        • Functions

        • Include files

        • Object wrappers

        • Consider using version control

      • Robustness

        • Unavailability of service

        • Unexpected variable types

      • Efficiency and Conciseness

        • Efficiency: Only the algorithm matters

        • Efficiency optimization tips

        • Conciseness: The downside

        • Conciseness tips

      • HTML Mode or PHP Mode?

        • Minimal PHP

        • Maximal PHP

        • Medium PHP

        • The heredoc style

      • Separating Code from Design

        • Functions

        • Cascading style sheets in PHP

        • Templates and page consistency

      • Summary

  • Part IV: Connections

    • Chapter 34: PostgreSQL

      • Why Choose PostgreSQL?

      • Why Object-Relational Anyway?

      • Installing PostgreSQL

        • Linux installation

        • But is it a database yet?

      • Down to Real Work

      • PHP and PostgreSQL

      • The Cartoons Database

      • Summary

    • Chapter 35: Oracle

      • When Do You Need Oracle?

        • Money

        • Other rivalrous resources

        • Huge data sets

        • Lots of big formulaic writes or data munging

        • Triggers

        • Legal liability

        • Bottom line: Two-year outlook

      • Oracle and Web Architecture

        • Specialized team members

        • Shared development databases

        • Limited schema changes

        • Tools (or lack thereof)

        • Replication and failover

        • Data caching

      • Using OCI8 Functions

        • Escaping strings

        • Parsing and executing

        • Error reporting

        • Memory management

        • Ask for nulls

        • Fetching entire data sets

        • All caps

        • Transactionality

        • Stored procedures and cursors

      • Project: Point Editor

      • Project: Batch Editor

      • Summary

    • Chapter 36: PEAR Database Functions

      • The Debatable Virtue of Database Independence

        • Native database connectivity

        • Database abstraction

      • Pear DB Concepts

        • Data Source Names (DSNs)

        • Connection

        • Query

        • Row retrieval

        • Disconnection

        • A complete example

      • PEAR DB Functions

        • Members of the DB class

        • Members of the DB_Common class

        • Members of the DB_Result class

      • Summary

    • Chapter 37: E-mail

      • Understanding E-mail

        • TCP/IP server

        • Mail Transfer Agent, aka SMTP server

        • Mail spool

        • Mail User Agent, aka local mail client

        • Mail-retrieval program, aka POP/IMAP server

        • Mailing list manager

      • Receiving E-mail with PHP

        • Implementing from scratch

        • Modifying other people's PHP

        • Cosmetic changes

      • Sending E-mail with PHP

        • Windows configuration

        • Unix configuration

        • The mail function

      • More Fun with PHP E-mail

        • Sending mail from a form

        • Sending mail from a database

        • Sending attachments with MIME mail

        • A custom PHP mail application

        • Sending mail from a cronjob

      • E-mail Gotchas

      • Summary

    • Chapter 38: PHP and JavaScript

      • Outputting JavaScript with PHP

        • Dueling objects

        • PHP doesn't care what it outputs

        • Where to use JavaScript

      • PHP as a Backup for JavaScript

      • Static Versus Dynamic JavaScript

        • Dynamically generated forms

        • Passing data back to PHP from JavaScript

      • Summary

    • Chapter 39: PHP and Java

      • PHP for Java programmers

        • Similarities

        • Differences

        • Java Server Pages and PHP

        • Guide to this book

      • Integrating PHP and Java

        • The Java SAPI

        • The Java extension

        • The Java object

        • Errors and exceptions

        • Potential gotchas

        • The sky's the limit

      • Summary

    • Chapter 40: PHP and XML

      • What Is XML?

      • Working with XML

      • Documents and DTDs

        • The structure of a DTD

        • Validating and nonvalidating parsers

      • SAX versus DOM

      • DOM

        • Using DOM XML

        • DOM functions

      • SAX

        • Using SAX

        • SAX options

        • SAX functions

      • SimpleXML API

        • Using SimpleXML

        • SimpleXML functions

      • A Sample XML Application

      • Gotchas and Troubleshooting

      • Summary

    • Chapter 41: Web Services

      • The End of Programming as We Know It

        • The ugly truth about data munging

        • Brutal simplicity

      • REST, XML-RPC, SOAP, .NET

        • REST

        • XML-RPC

        • SOAP

        • .NET services

      • Current Issues with Web Services

        • Fat and slow

        • Potentially heavy load

        • Standards

        • Hide and seek

        • Who pays and how?

      • Project: A REST Client

      • Project: A SOAP Server and Client

      • Summary

    • Chapter 42: Graphics

      • Your Options

      • HTML Graphics

      • Creating images using gd

        • What is gd?

        • Image formats and browsers

        • Choosing versions

        • Installation

        • gd Concepts

        • Functions

        • Images and HTTP

        • Example: Fractal images

      • Gotchas and Troubleshooting

        • Symptom: Completely blank image

        • Symptom: Headers already sent

        • Symptom: Broken image

      • Summary

  • Part V: Case Studies

    • Chapter 43: Weblogs

      • Why Weblogs?

      • The Simplest Weblog

      • Adding an HTML Editing Tool

      • Adding Database Connectivity

      • Changes and Additions

      • Summary

    • Chapter 44: User Authentication

      • Designing a User-Authentication System

      • Avoiding Common Security Issues

        • Turn off register_globals

        • Check for string length and safety

        • One-way encrypt passwords

      • Registration

      • Login/Logout

      • User Tools

        • Forgotten password

        • Changing sensitive user data

        • Edit non-sensitive user data

      • Administrator Tools

        • Authorization: Basic auth, cookie, database, and IP

        • Login as user

      • Summary

    • Chapter 45: A User-Rating System

      • Initial Design

        • Domain: A quotation site

        • Possible ratings

        • Linking ratings with content

      • Collecting Votes

      • Aggregating Results

      • Extensions and Alternatives

      • Summary

    • Chapter 46: A Trivia Game

      • Concepts Used in This Chapter

      • The Game

        • Our version

        • Sample screens

        • The rules

        • Playing the game yourself

      • The Code

        • Code files

        • Creating the database

      • General Design Considerations

        • Separation of code and display

        • Persistence of data

        • Exception handling

      • Summary

    • Chapter 47: Converting Static HTML Sites

      • Planning the Big Upgrade

        • The baby and the bathwater

        • Technical assessment

      • Redesigning the User Interface

      • Planning a New Database Schema

      • Dumping Data into a Database

        • Data-massaging

        • Data dumping

        • Harvesting data

      • Templating

      • Performance and Caching

        • Caching

      • Summary

    • Chapter 48: Data Visualization with Venn Diagrams

    • Scaled Venn Diagrams

      • The task

    • Outline of the Code

    • Necessary Trigonometry

    • Planning the Display

      • Simplifying assumptions

      • Determining size and scale

    • Display

    • Visualizing a Database

      • Trying it out

    • Extensions

    • Summary

  • Appendix A: PHP for C Programmers

  • Appendix B: PHP for Perl Hackers

  • Appendix C: PHP for HTML Coders

  • Appendix D: PHP Resources

  • Index

  • Team DDU

Nội dung

www.it-ebooks.info PHP5 and MySQL ® Bible Tim Converse and Joyce Park with Clark Morgan 01 557467 FM.qxd 4/5/04 11:09 AM Page iii www.it-ebooks.info 01 557467 FM.qxd 4/5/04 11:09 AM Page ii www.it-ebooks.info PHP5 and MySQL ® Bible 01 557467 FM.qxd 4/5/04 11:09 AM Page i www.it-ebooks.info 01 557467 FM.qxd 4/5/04 11:09 AM Page ii www.it-ebooks.info PHP5 and MySQL ® Bible Tim Converse and Joyce Park with Clark Morgan 01 557467 FM.qxd 4/5/04 11:09 AM Page iii www.it-ebooks.info LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. PHP5 and MySQL ® Bible Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 0-7645-5746-7 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/SR/QU/QU/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail: permcoordinator@wiley.com. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2004103176 Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. MySQL is a registered trademark of MySQL AB Limited Company. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. 01 557467 FM.qxd 4/5/04 11:09 AM Page iv www.it-ebooks.info About the Authors Tim Converse has written software to recommend neckties, answer questions about space stations, pick value stocks, and make simulated breakfast. He has an M.S. in Computer Science from the University of Chicago, where he taught several programming classes. He is now an engineering manager in the Web search group at Yahoo!. Joyce Park has an M.A. in history from the University of Chicago, and has worked for several Silicon Valley startups including Epinions, KnowNow, and Friendster. She is a co-lead of the Mod-pubsub Open Source project. Clark Morgan is a Web application and educational software developer with more than five years’ experience writing PHP. He works primarily with medical clients and related busi- nesses. Originally from Boston, he now lives and works in Jacksonville, Florida, with his wife and two children. Clark spends entirely too much of his free time reading other people’s com- puter books. 01 557467 FM.qxd 4/5/04 11:09 AM Page v www.it-ebooks.info Credits Acquisitions Editor Debra Williams Cauley Development Editor Sara Shlaer Production Editor Eric Newman Technical Editors Chris Cornell David Wall Copy Editor C. M. Jones Editorial Manager Mary Beth Wakefield Vice President & Executive Group Publisher Richard Swadley Vice President and Executive Publisher Bob Ipsen Vice President and Publisher Joseph B. Wikert Executive Editorial Director Mary Bednarek Project Coordinator April Farling Graphics and Production Specialists Beth Brooks Sean Decker Carrie Foster Lauren Goddard Quality Control Technician Laura Albert Carl William Pierce Permissions Editor Carmen Krikorian Media Development Specialist Angela Denny Proofreading and Indexing TECHBOOKS Production Services 01 557467 FM.qxd 4/5/04 11:09 AM Page vi www.it-ebooks.info To our parents: For their love, for their sacrifices, and for letting us read a lot when we were kids. — Tim Converse and Joyce Park This, my first serious writing effort, is for my lifelong friend Bob, who pointed me in this direction nearly ten years ago and then had the nerve to suggest I write about it. — Clark Morgan 01 557467 FM.qxd 4/5/04 11:09 AM Page vii www.it-ebooks.info [...]... II: PHP and MySQL Part II is devoted both to MySQL and to PHP’s interaction with MySQL ✦ Chapters 12 and 13 provide a general orientation to Web programming with SQL databases, including advice on how to choose the database system that is right for you ✦ Chapter 14 covers installation and administration of MySQL databases, and Chapter 15 is devoted to PHP functions for MySQL ✦ Chapters 16 and 17 are... Administration 259 MySQL Licensing Installing MySQL: Moving to Version 4 Preinstall considerations Downloading MySQL Installing MySQL on Windows Installing MySQL on Unix Installing MySQL on Mac OS X Post-installation housekeeping Basic MySQL client commands MySQL User Administration Local development Standalone Web site Shared-hosting... survives unchanged in PHP5, there have been some deep changes Among the ones we cover are: ✦ Zend Engine 2 and the new object model, with support for private/protected members, abstract classes, and interfaces ✦ PHP5 s completely reworked XML support, built around libmxl2 ✦ Exceptions and exception handling MySQL coverage We now cover MySQL 4.0 installation, database design, and administration, including... to PHP5 and MySQL Bible! Although we’re biased, we believe that the PHP Web-scripting language is the hands-down winner in its niche — by far the easiest and most flexible server-side tool for getting great Web sites up and running in a hurry Although millions of Web programmers worldwide could be wrong, in this particular case, they’re not MySQL is the most popular open-source database platform, and. .. case studies of PHP /MySQL interactions ✦ Chapters 18 and 19 provide tips and gotchas specific to PHP /MySQL work www.it-ebooks.info xi xii Preface Part III: Advanced Features and Techniques In this part we cover more advanced and abstruse features of PHP, usually as self-contained chapters, including object-oriented programming, session handling, exception handling, using cookies, and regular expressions... second edition and bring it up to date with PHP5 We realized, however, that although the previous editions covered PHP /MySQL interaction, we had left readers in the dark about how to create and administer MySQL databases in the first place, and this led to many reader questions As a result, we decided to beef up the coverage of MySQL and change the title www.it-ebooks.info x Preface New PHP5 features... replication, and recovery As with previous editions, we devote much of the book to techniques for writing MySQL- backed PHP applications Other new material In addition to MySQL- and PHP5- specific features, we’ve added: ✦ Improved coverage of databases other than MySQL (Oracle, PostgreSQL, and the PEAR database interaction layer) ✦ The PEAR code repository ✦ A chapter on integrating PHP and Java ✦ Separate... xv Part I: PHP: The Basics 1 Chapter 1: Why PHP and MySQL? 3 What Is PHP? 3 What Is MySQL? 4 The History of PHP 4 The History of MySQL 5 Reasons to Love PHP and MySQL 6 Cost ... 265 268 268 269 269 272 274 276 277 278 278 Chapter 15: PHP /MySQL Functions 279 Connecting to MySQL Making MySQL Queries Fetching Data Sets Getting Data about Data Multiple Connections Building in Error Checking Creating MySQL Databases with PHP MySQL data types MySQL Functions Summary ... through 42 cover self-contained topics: PHP and e-mail programs, combining PHP with JavaScript, integrating PHP and Java, PHP and XML, PHP-based Web services, and creating graphics with the gd image library Part V: Case Studies Here we present six extended case studies that wrap together techniques from various early chapters ✦ Chapter 43 takes you through the design and implementation of a weblog ✦ Chapter . ii www.it-ebooks.info PHP5 and MySQL ® Bible 01 557467 FM.qxd 4/5/04 11:09 AM Page i www.it-ebooks.info 01 557467 FM.qxd 4/5/04 11:09 AM Page ii www.it-ebooks.info PHP5 and. Exceptions and exception handling MySQL coverage We now cover MySQL 4.0 installation, database design, and administration, including back- ups, replication, and

Ngày đăng: 07/03/2014, 21:20

TỪ KHÓA LIÊN QUAN