did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781590595527

Beginning PHP and MySQL 5

by
  • ISBN13:

    9781590595527

  • ISBN10:

    1590595521

  • Edition: 2nd
  • Format: Paperback
  • Copyright: 2006-01-30
  • Publisher: Apress

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $44.99 Save up to $29.80
  • Buy Used
    $33.74

    USUALLY SHIPS IN 2-4 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

Beginning PHP 5 and MySQL 5: From Novice to Professional 2/e offers comprehensive information about two of the most prominent open source technologies on the planet: the PHP scripting language and the MySQL database server. Essentially three books in one, this second edition covers PHP 5, MySQL 5, and how these two popular open source technologies work together to create powerful websites. The book is packed with practical examples and insight into real-world challenges. It is based on the author's 7 years of experience working with these technologies. You will repeatedly refer to this book as a valuable instructional tool and reference guide.

Table of Contents

About the Author xxvii
About the Technical Reviewer xxix
Acknowledgments xxxi
Introduction xxxiii
An Introduction to PHP
1(8)
History
1(3)
PHP 4
2(1)
PHP 5
3(1)
General Language Features
4(3)
Practicality
5(1)
Power
5(1)
Possibility
6(1)
Price
7(1)
Summary
7(2)
Installing and Configuring Apache and PHP
9(34)
Installation
9(10)
Obtaining the Distributions
9(2)
The Installation Process
11(5)
Testing Your Installation
16(1)
Customizing the Unix Build
17(1)
Customizing the Windows Build
18(1)
Common Pitfalls
18(1)
Viewing and Downloading the Documentation
19(1)
Configuration
19(23)
Managing PHP's Configuration Directives
20(2)
PHP's Configuration Directives
22(20)
Summary
42(1)
PHP Basics
43(48)
Escaping to PHP
43(3)
Default Syntax
44(1)
Short-Tags
44(1)
Script
45(1)
ASP-Style
45(1)
Embedding Multiple Code Blocks
45(1)
Comments
46(1)
Single-line C++ Syntax
46(1)
Shell Syntax
46(1)
Multiple-Line C Syntax
46(1)
Output
47(3)
print()
47(1)
echo()
48(1)
printf()
49(1)
sprintf()
50(1)
Datatypes
50(7)
Scalar Datatypes
50(2)
Compound Datatypes
52(1)
Special Datatypes
53(1)
Type Casting
54(1)
Type Juggling
55(1)
Type-Related Functions
56(1)
Type Identifier Functions
57(1)
Identifiers
57(1)
Variables
58(10)
Variable Declaration
58(2)
Variable Scope
60(3)
PHP's Superglobal Variables
63(4)
Variable Variables
67(1)
Constants
68(1)
Expressions
68(7)
Operands
69(1)
Operators
69(6)
String Interpolation
75(3)
Double Quotes
75(1)
Single Quotes
76(1)
Heredoc
77(1)
Control Structures
78(11)
Execution Control Statements
78(1)
Conditional Statements
79(2)
Looping Statements
81(5)
File Inclusion Statements
86(3)
Summary
89(2)
Functions
91(12)
Invoking a Function
91(1)
Creating a Function
92(8)
Passing Arguments by Value
92(1)
Passing Arguments by Reference
93(1)
Default Argument Values
94(1)
Optional Arguments
94(1)
Returning Values from a Function
95(1)
Nesting Functions
96(1)
Recursive Functions
97(2)
Variable Functions
99(1)
Function Libraries
100(1)
Summary
101(2)
Arrays
103(30)
What Is an Array?
104(1)
Outputting Arrays
105(1)
Creating an Array
106(2)
Testing for an Array
108(1)
Adding and Removing Array Elements
109(2)
Locating Array Elements
111(1)
Traversing Arrays
112(4)
Determining Array Size and Uniqueness
116(2)
Sorting Arrays
118(6)
Merging, Slicing, Splicing, and Dissecting Arrays
124(5)
Other Useful Array Functions
129(2)
Summary
131(2)
Object-Oriented PHP
133(24)
The Benefits of OOP
134(1)
Encapsulation
134(1)
Inheritance
134(1)
Polymorphism
135(1)
Key OOP Concepts
135(12)
Classes
135(1)
Objects
136(1)
Fields
137(3)
Properties
140(1)
__set()
140(3)
Constants
143(1)
Methods
143(4)
Type Hinting
147(1)
Constructors and Destructors
148(4)
Constructors
148(3)
Destructors
151(1)
Static Class Members
152(1)
The instanceof Keyword
153(1)
Helper Functions
153(2)
Autoloading Objects
155(1)
Summary
156(1)
Advanced OOP Features
157(20)
Advanced OOP Features Not Supported by PHP
157(1)
Object Cloning
158(3)
Cloning Example
158(2)
The __clone() Method
160(1)
Inheritance
161(4)
Class Inheritance
162(2)
Inheritance and Constructors
164(1)
Interfaces
165(3)
Implementing a Single Interface
167(1)
Implementing Multiple Interfaces
168(1)
Abstract Classes
168(1)
Reflection
169(7)
Writing the ReflectionClass Class
170(2)
Writing the ReflectionMethod Class
172(2)
Writing the ReflectionParameter Class
174(1)
Writing the ReflectionProperty Class
175(1)
Other Reflection Applications
176(1)
Summary
176(1)
Error and Exception Handling
177(14)
Configuration Directives
177(3)
Error Logging
180(3)
Exception Handling
183(6)
Why Exception Handling Is Handy
183(2)
PHP's Exception-Handling Implementation
185(4)
Summary
189(2)
Strings and Regular Expressions
191(38)
Complex (Curly) Offset Syntax
191(1)
Regular Expressions
192(13)
Regular Expression Syntax (POSIX)
193(2)
PHP's Regular Expression Functions (POSIX Extended)
195(3)
Regular Expression Syntax (Perl Style)
198(7)
Other String-Specific Functions
205(21)
Determining the Length of a String
205(1)
Comparing Two Strings
206(2)
Manipulating String Case
208(1)
Converting Strings to and from HTML
209(5)
Alternatives for Regular Expression Functions
214(8)
Padding and Stripping a String
222(2)
Counting Characters and Words
224(2)
Taking Advantage of PEAR: Validate_US
226(1)
Installing Validate_US
226(1)
Using Validate_US
227(1)
Summary
227(2)
Working with the File and Operating System
229(30)
Learning About Files and Directories
230(9)
Parsing Directory Paths
230(2)
File Types and Links
232(3)
Calculating File, Directory, and Disk Sizes
235(3)
Access and Modification Times
238(1)
File Ownership and Permissions
239(3)
File I/O
242(10)
The Concept of a Resource
242(1)
Newline
242(1)
End-of-File
242(1)
Opening and Closing a File
242(2)
Reading from a File
244(5)
Moving the File Pointer
249(1)
Writing to a File
250(1)
Reading Directory Contents
251(1)
Executing Shell Commands
252(2)
PHP's Built-in System Commands
252(2)
System-Level Program Execution
254(4)
Sanitizing the Input
254(1)
PHP's Program Execution Functions
255(3)
Summary
258(1)
PEAR
259(12)
Popular PEAR Packages
259(3)
Converting Numeral Formats
261(1)
Installing and Updating PEAR
262(2)
Installing PEAR
262(1)
PEAR and Hosting Companies
263(1)
Updating PEAR
264(1)
Using the PEAR Package Manager
264(6)
Viewing Installed Packages
264(1)
Learning More About an Installed Package
265(1)
Installing a Package
266(1)
Using a Package
267(1)
Upgrading a Package
268(1)
Uninstalling a Package
269(1)
Downgrading a Package
269(1)
Summary
270(1)
Date and Time
271(32)
The Unix Timestamp
271(1)
PHP's Date and Time Library
272(7)
Date Fu
279(9)
Displaying the Localized Date and Time
279(4)
Displaying the Web Page's Most Recent Modification Date
283(1)
Determining the Number Days in the Current Month
283(1)
Calculating the Date X Days from the Present Date
284(1)
Creating a Calendar
285(3)
PHP 5.1
288(13)
Date Fundamentals
289(1)
The Date Constructor
289(1)
Accessors and Mutators
290(3)
Validators
293(1)
Manipulation Methods
294(7)
Summary
301(2)
Forms and Navigational Cues
303(22)
PHP and Web Forms
303(10)
A Simple Example
304(2)
Passing Form Data to a Function
306(1)
Working with Multivalued Form Components
307(1)
Generating Forms with PHP
308(2)
Autoselecting Forms Data
310(1)
PHP, Web Forms, and JavaScript
311(2)
Navigational Cues
313(10)
User-Friendly URLs
313(4)
Breadcrumb Trails
317(4)
Creating Custom Error Handlers
321(2)
Summary
323(2)
Authentication
325(20)
HTTP Authentication Concepts
325(1)
PHP Authentication
326(11)
Authentication Variables
327(1)
Authentication Methodologies
328(9)
User Login Administration
337(8)
Password Designation
337(2)
Testing Password Guessability with the CrackLib Library
339(2)
One-Time URLs and Password Recovery
341(4)
Handling File Uploads
345(14)
Uploading Files via the HTTP Protocol
345(1)
Handling Uploads with PHP
346(9)
PHP's File Upload/Resource Directives
346(2)
The $_FILES Array
348(1)
PHP's File-Upload Functions
349(1)
Upload Error Messages
350(1)
File-Upload Examples
351(4)
Taking Advantage of PEAR: HTTP_Upload
355(3)
Installing HTTP_Upload
355(1)
Learning More About an Uploaded File
355(1)
Moving an Uploaded File to the Final Destination
356(1)
Uploading Multiple Files
357(1)
Summary
358(1)
Networking
359(40)
DNS, Services, and Servers
360(7)
DNS
360(4)
Services
364(1)
Establishing Socket Connections
365(2)
Mail
367(5)
Configuration Directives
367(2)
Sending a Plain-Text E-Mail
369(1)
Sending an E-Mail with Additional Headers
369(1)
Sending an E-Mail to Multiple Recipients
369(1)
Sending an HTML-Formatted E-Mail
370(1)
Sending an Attachment
371(1)
IMAP, POP3, and NNTP
372(18)
Requirements
373(1)
Establishing and Closing a Connection
374(1)
Learning More About Mailboxes and Mail
375(3)
Retrieving Messages
378(8)
Composing a Message
386(1)
Sending a Message
387(1)
Mailbox Administration
388(1)
Message Administration
389(1)
Streams
390(3)
Stream Wrappers and Contexts
390(1)
Stream Filters
391(2)
Common Networking Tasks
393(5)
Pinging a Server
394(1)
A Port Scanner
395(1)
Subnet Converter
395(2)
Testing User Bandwidth
397(1)
Summary
398(1)
PHP and LDAP
399(26)
An Introduction to LDAP
400(1)
Learning More About LDAP
400(1)
Using LDAP from PHP
401(22)
Connecting to the LDAP Server
401(1)
Binding to the LDAP Server
402(1)
Closing the LDAP Server Connection
403(1)
Retrieving LDAP Data
404(1)
Working with Entry Values
405(2)
Counting Retrieved Entries
407(1)
Retrieving Attributes
407(3)
Sorting and Comparing LDAP Entries
410(2)
Working with Entries
412(3)
Deallocating Memory
415(1)
Inserting LDAP Data
415(2)
Updating LDAP Data
417(1)
Deleting LDAP Data
417(1)
Configuration Functions
418(2)
Character Encoding
420(1)
Working with the Distinguished Name
421(1)
Error Handling
422(1)
Summary
423(2)
Session Handlers
425(22)
What Is Session Handling?
425(2)
Cookies
426(1)
URL Rewriting
426(1)
The Session-Handling Process
426(1)
Configuration Directives
427(5)
Key Concepts
432(5)
Starting a Session
432(1)
Destroying a Session
433(1)
Retrieving and Setting the Session ID
434(1)
Creating and Deleting Session Variables
434(1)
Encoding and Decoding Session Data
435(2)
Practical Session-Handling Examples
437(4)
Auto-Login
437(2)
Recently Viewed Document Index
439(2)
Creating Custom Session Handlers
441(4)
Tying Custom Session Functions into PHP's Logic
442(1)
Custom MySQL-Based Session Handlers
442(3)
Summary
445(2)
Templating with Smarty
447(26)
What's a Templating Engine?
447(2)
Introducing Smarty
449(1)
Installing Smarty
450(2)
Using Smarty
452(2)
Smarty's Presentational Logic
454(11)
Comments
454(1)
Variable Modifiers
454(3)
Control Structures
457(5)
Statements
462(3)
Creating Configuration Files
465(2)
config load
465(1)
Referencing Configuration Variables
466(1)
Using CSS in Conjunction with Smarty
467(1)
Caching
468(3)
Working with the Cache Lifetime
468(1)
Eliminating Processing Overhead with is_cached()
469(1)
Creating Multiple Caches per Template
470(1)
Some Final Words About Caching
471(1)
Summary
471(2)
Web Services
473(42)
Why Web Services?
474(2)
Real Simple Syndication
476(10)
RSS Syntax
478(1)
MagpieRSS
479(7)
SimpleXML
486(5)
SimpleXML Functions
486(2)
SimpleXML Methods
488(3)
SOAP
491(21)
NuSOAP
492(10)
PHP 5's SOAP Extension
502(10)
Using a C# Client with a PHP Web Service
512(2)
Summary
514(1)
Secure PHP Programming
515(20)
Configuring PHP Securely
516(4)
Safe Mode
516(2)
Other Security-Related Configuration Parameters
518(2)
Hiding Configuration Details
520(2)
Hiding Apache and PHP
520(2)
Hiding Sensitive Data
522(2)
Take Heed of the Document Root
523(1)
Denying Access to Certain File Extensions
523(1)
Sanitizing User Data
524(4)
File Deletion
524(1)
Cross-Site Scripting
524(2)
Sanitizing User Input: The Solution
526(2)
Data Encryption
528(4)
PHP's Encryption Functions
528(1)
mhash
529(2)
MCrypt
531(1)
Summary
532(3)
SQLite
535(20)
Introduction to SQLite
535(2)
Installing SQLite
536(1)
Using the SQLite Command-Line Interface
536(1)
PHP's SQLite Library
537(16)
SQLite Directives
537(1)
Opening a Connection
538(1)
Creating a Table in Memory
539(1)
Closing a Connection
539(1)
Querying a Database
540(1)
Parsing Result Sets
541(3)
Retrieving Result Set Details
544(2)
Manipulating the Result Set Pointer
546(2)
Learning More About Table Schemas
548(1)
Working with Binary Data
549(1)
Creating and Overriding SQLite Functions
550(1)
Creating Aggregate Functions
551(2)
Summary
553(2)
Introducing PDO
555(18)
Another Database Abstraction Layer?
556(1)
Using PDO
557(15)
Installing PDO
558(1)
PDO's Database Support
558(1)
Connecting to a Database Server and Selecting a Database
559(2)
Getting and Setting Attributes
561(1)
Error Handling
562(1)
Query Execution
562(2)
Prepared Statements
564(3)
Retrieving Data
567(4)
Setting Bound Columns
571(1)
Transactions
572(1)
Summary
572(1)
Introducing MySQL
573(8)
What Makes MySQL So Popular?
573(4)
Flexibility
574(1)
Power
574(2)
Flexible Licensing Options
576(1)
A (Hyper) Active User Community
577(1)
MySQL 4
577(1)
MySQL 5
578(1)
Prominent MySQL Users
579(1)
craigslist
579(1)
Yahoo! Finance
580(1)
Wikipedia
580(1)
Summary
580(1)
Installing and Configuring MySQL
581(26)
PHP and MySQL Licensing Issues
581(2)
Linux
582(1)
Windows
582(1)
Downloading MySQL
583(1)
Installing MySQL
584(7)
Linux
584(4)
Windows
588(3)
Set the MySQL Administrator Password
591(1)
Starting and Stopping MySQL
591(5)
Controlling the Daemon Manually
592(2)
Starting and Stopping MySQL Automatically
594(2)
Configuring and Optimizing MySQL
596(9)
mysqld_safe
597(1)
Configuration and Optimization Parameters
597(5)
The my.cnf File
602(3)
Summary
605(2)
The Many MySQL Clients
607(24)
Standard Client Options
607(1)
Connection Options
608(1)
General Options
609(1)
mysql
610(9)
Key mysql Options
610(2)
Using mysql in Interactive Mode
612(2)
Viewing Configuration Variables and System Status
614(2)
Using mysql in Batch Mode
616(1)
Useful mysql Tips
616(3)
mysqladmin
619(2)
mysqladmin Commands
619(2)
The Other Utilities
621(3)
mysqldump
621(1)
mysqlshow
621(1)
mysqlhotcopy
622(1)
mysqlimport
623(1)
myisamchk
623(1)
mysqlcheck
624(1)
Third-Party Client Programs
624(6)
MySQL Administrator
624(2)
phpMyAdmin
626(1)
MySQL Query Browser
627(2)
Navicat
629(1)
Summary
630(1)
MySQL Storage Engines and Datatypes
631(30)
Storage Engines
631(11)
InnoDB
632(1)
MyISAM
633(2)
Memory
635(1)
Merge
636(1)
BDB
637(1)
Federated
637(1)
Archive
638(1)
CSV
639(1)
Example
640(1)
Blackhole
640(1)
Storage Engine FAQ
640(2)
Datatypes and Attributes
642(9)
Datatypes
642(6)
Datatype Attributes
648(3)
Working with Databases and Tables
651(8)
Working with Databases
651(2)
Working with Tables
653(3)
Altering a Table Structure
656(1)
The Information_Schema
656(3)
Summary
659(2)
Securing MySQL
661(28)
What You Should Do First
661(1)
Securing the mysqld Daemon
662(1)
The MySQL Access Privilege System
663(12)
How the Privilege System Works
663(2)
Where Is Access Information Stored?
665(10)
User and Privilege Management
675(7)
Create User
675(1)
Drop User
676(1)
Rename User
676(1)
The Grant and Revoke Commands
676(6)
Reviewing Privileges
682(1)
Limiting User Resources
682(1)
Secure MySQL Connections
683(4)
Grant Options
683(2)
SSL Options
685(1)
Starting the SSL-Enabled MySQL Server
686(1)
Connecting Using an SSL-Enabled Client
686(1)
Storing SSL Options in the my.cnf File
686(1)
Summary
687(2)
PHP's MySQL Extension
689(30)
Prerequisites
689(1)
Enabling the MySQL Extension on Linux
689(1)
Enabling the MySQL Extension on Windows
690(1)
User Privileges
690(1)
Sample Data
690(1)
PHP's MySQL Commands
690(4)
Establishing and Closing a Connection
691(2)
Storing Connection Information in a Separate File
693(1)
Securing Your Connection Information
693(1)
Choosing a Database
694(1)
Querying MySQL
694(2)
Retrieving and Displaying Data
696(3)
Inserting Data
699(2)
Modifying Data
701(3)
Deleting Data
704(1)
Rows Selected and Rows Affected
705(1)
Retrieving Database and Table Information
706(2)
Retrieving Field Information
708(7)
Viewing Table Properties
712(1)
Retrieving Error Information
713(2)
Helper Functions
715(3)
Summary
718(1)
PHP's mysqli Extension
719(26)
Prerequisites
720(1)
Enabling the mysqli Extension on Unix
720(1)
Enabling the mysqli Extension on Windows
720(1)
Sample Data
721(1)
Using the mysqli Extension
721(5)
Connecting to the MySQL Server
721(1)
Connection Error Reporting
722(3)
Selecting a MySQL Database
725(1)
Closing a MySQL Connection
725(1)
Queries
726(15)
Query Execution
726(2)
Recuperating Query Memory
728(1)
Readying the Result Set
728(2)
Parsing Results
730(3)
Multiple Queries
733(2)
Prepared Statements
735(6)
Database Transactions
741(2)
Summary
743(2)
Stored Routines
745(22)
Should You Use Stored Routines?
745(2)
Stored Routine Advantages
746(1)
Stored Routine Disadvantages
746(1)
How MySQL Implements Stored Routines
747(17)
Stored Routine Privilege Tables
747(2)
Creating a Stored Routine
749(2)
Declaring and Setting Variables
751(2)
Executing a Stored Routine
753(1)
Multistatement Stored Routines
753(8)
Calling a Routine from Within Another Routine
761(1)
Modifying a Stored Routine
761(1)
Deleting a Stored Routine
762(1)
Viewing a Routine's Status
762(1)
Viewing a Routine's Creation Syntax
763(1)
Conditions and Handlers
764(1)
Integrating Routines into Web Applications
764(2)
Creating the Employee Bonus Interface
764(1)
Retrieving Multiple Rows
765(1)
Summary
766(1)
MySQL Triggers
767(12)
Introducing Triggers
767(3)
Why Use Triggers?
768(1)
Taking Action Before an Event
768(1)
Taking Action After an Event
768(1)
Before Triggers vs. After Triggers
769(1)
MySQL's Trigger Support
770(6)
Creating a Trigger
771(1)
Viewing Existing Triggers
772(2)
Modifying a Trigger
774(1)
Deleting a Trigger
774(1)
Cascading Triggers
775(1)
Integrating Triggers into Web Applications
776(2)
Summary
778(1)
Views
779(14)
Introducing Views
780(1)
MySQL's View Support
780(9)
Creating and Executing Views
781(5)
Viewing View Information
786(2)
Modifying a View
788(1)
Deleting a View
788(1)
Updating Views
788(1)
Incorporating Views into Web Applications
789(2)
Summary
791(2)
Practical Database Queries
793(24)
Sample Data
794(1)
Creating Tabular Output with PEAR
794(8)
Installing HTML_Table
795(1)
Creating a Simple Table
795(2)
Creating More Readable Row Output
797(1)
Creating a Table from Database Data
798(1)
Generalizing the Output Process
799(3)
Sorting Output
802(1)
Creating Paged Output
803(3)
Listing Page Numbers
806(2)
Subqueries
808(4)
Performing Comparisons with Subqueries
809(1)
Determining Existence with Subqueries
809(2)
Database Maintenance with Subqueries
811(1)
Using Subqueries with PHP
811(1)
Cursors
812(3)
Cursor Basics
812(1)
Creating a Cursor
813(1)
Opening a Cursor
813(1)
Using a Cursor
813(2)
Closing a Cursor
815(1)
Using Cursors with PHP
815(1)
Summary
815(2)
Indexes and Searching
817(14)
Database Indexing
817(9)
Primary Key Indexes
818(1)
Unique Indexes
819(1)
Normal Indexes
820(2)
Full-Text Indexes
822(3)
Indexing Best Practices
825(1)
Forms-Based Searches
826(4)
Performing a Simple Search
826(1)
Extending Search Capabilities
827(2)
Performing a Full-Text Search
829(1)
Summary
830(1)
Transactions
831(14)
What's a Transaction?
831(1)
MySQL's Transactional Capabilities
832(4)
System Requirements
832(1)
Table Creation
833(1)
InnoDB Configuration Parameters
833(3)
A Sample Project
836(4)
Sample Data
836(1)
Executing an Example Transaction
837(2)
Backing Up and Restoring InnoDB Tables
839(1)
Usage Tips
839(1)
Building Transactional Applications with PHP
840(3)
The Swap Meet Revisited
840(3)
Summary
843(2)
Importing and Exporting Data
845(14)
Sample Table
845(1)
Attaining a Happy Medium
846(1)
Exporting Data
846(4)
Select into Outfile
847(3)
Importing Data
850(7)
Importing Data with Load Data Infile
850(3)
Importing with mysqlimport
853(3)
Loading Table Data with PHP
856(1)
Summary
857(2)
Index 859

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program