PHP and MySQL Web Development, Second Edition

( 5 )


PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP.

The book teaches the reader to integrate and implement these technologies by following real-world examples and working sample projects, and also covers related technologies ...

See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (34) from $1.99   
  • New (3) from $50.00   
  • Used (31) from $1.99   
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any coupons and promotions
Seller since 2014

Feedback rating:



New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Seller since 2014

Feedback rating:


Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Seller since 2014

Feedback rating:


Condition: New
New New condition. Free track. Fast shipping! Satisfaction guaranteed!

Ships from: Media, PA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Sort by
Sending request ...


PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP.

The book teaches the reader to integrate and implement these technologies by following real-world examples and working sample projects, and also covers related technologies needed to build a commercial Web site, such as SSL, shopping carts, and payment systems.

The second edition includes new coverage of how to work with XML in developing a PHP and MySQL site, and how to draw on the valuable resources of the PEAR repository of code and extensions.

An intermediate to advanced guide to PHP and MySQL, the free, open-sourced Web development products. Offers coverage of object-oriented Web programming, creating services using SSL and authentication, and other applications. The CD-ROM contains the source code for the text, PHP4 source code and binaries, and other tools.

Read More Show Less

Editorial Reviews

From Barnes & Noble
The Barnes & Noble Review
Every once in awhile, it's nice to step back and marvel at how much you can accomplish without spending a dime on software. Take, for example, the combination of the PHP scripting language and the MySQL database: together, they can do virtually everything needed by the vast majority of dynamic, database-driven web sites. And, with the right kind of help, they're really not that hard to use.

Thousands of web developers have found exactly the help they needed in PHP and MySQL Web Development. Now, Luke Welling and Laura Thomson have updated their outstanding guide to reflect the latest versions of both MySQL (4.0) and PHP (4.2). They've also added new coverage of XML, as well as the new PEAR framework and distribution system for reusable PHP components -- a great resource for folks who'd rather not write all their code from scratch.

As in the first edition, this book is packed with practical sample code (all of it on the accompanying CD-ROM). The authors begin with a crash course on PHP itself: basic syntax, storing and retrieving data from simple flat file databases, using arrays; working with strings and regular expressions; functions; code reuse; and finally, object-oriented PHP techniques.

Next, you'll master MySQL: designing, creating, and working with databases for web applications plus using PHP to access MySQL databases. Welling and Thomson show how to use MySQL's privilege system to secure your databases more effectively, explaining the GRANT command first introduced in MySQL version 3.22.11; the mysql tables that store user and privilege information; and the new security issues that arise when you connect databases to the Web.

Next, they briefly introduce several practical techniques for optimizing your database's performance: minimizing redundancy through careful design; simplifying permissions; optimizing tables; and using indexes.

Once you have the grounding you need, the authors present detailed techniques for building real-world applications. There's an entire section on e-commerce, with detailed chapters on managing e-commerce sites and security, implementing authentication with PHP and MySQL, and, finally, securing transactions. And you'll find chapter-length coverage of networking, session control, interactions with filesystems and servers, managing dates and times, generating images, debugging, and other useful features.

The book also contains seven start-to-finish projects, ranging from content management to email, from generating on-the-fly PDFs to connecting with web services via SOAP.

These application case studies are wonderfully detailed, with clear explanations of the problems they're designed to solve, and simple diagrams explaining the program's system flow and how its modules fit together. What's more, they draw on a wide variety of PHP resources, demonstrating the breadth and depth of this language's capabilities -- and that of the community which surrounds it.

For example, using PHP's IMAP function library, you'll build a complete web-based email client that connects to an existing mail server. (They call their program Warm Mail, which should give you an idea of the model.) Warm Mail allows users to connect to their email accounts, read and send mail, forward and reply to messages, and delete mail -- in short, it's a pretty good workout of PHP's mail capabilities.

Then, in the following chapter, you'll implement a front-end for a mailing list manager customized for managing online newsletters. This app has a pretty long list of requirements: administrators should be able to set up and modify multiple mailing lists, then send text or HTML newsletters to each subscriber. Meanwhile, users should be able to register for the newsletter, enter and manage information about themselves, subscribe to multiple newsletters, unsubscribe to any of them, and view past newsletters. Plus, of course, all of this should be secure.

By the time you've developed this application, you ought to be able to write pretty much anything you need. Few books help you leverage this much power at this little cost. (Bill Camarda/Read Only)

Library Journal
These three guides cover the popular open-source programming language for creating dynamic web sites (see also Computer Media, LJ 3/1/02); libraries owning first editions should update. Essentials addresses topics from installing PHP to working with database systems. Advanced techniques cover working with images and XML, and appendixes include a language reference and recommended online resources. A useful and stripped-down introduction, appropriate for all libraries.Web Development, appropriate for larger libraries and intermediate programmers, focuses on the use of PHP with the equally popular MySQL. Part 1 explains using the language, while Part 2 adds extra value with thorough explanations of real-world projects such as user authentication, shopping carts, and online forums. Appendixes cover installing PHP, Apache, and MySQL under both UNIX and Windows and recommended resources; the CD contains source code, software, and the entire title in PDF format. A good crash course in building dynamic web sites with the two technologies; buy in conjunction with more basic guides. Core relates to intermediate to advanced programmers, tackling the new features and useful functions of the yet-to-be-released PHP v.5. Sample code is provided; the authors ask readers to extend functionality on their own. Appendixes include escape sequences, ASCII codes, operators, tags, configuration, online resources, and a style guide. For libraries serving large programming communities. Copyright 2003 Reed Business Information.
Shows how to combine the PHP scripting language with the MySQL database to produce interactive web sites. The guide provides examples that demonstrate tasks such as authenticating users, constructing a shopping cart, generating PDF documents and images dynamically, sending and managing email, facilitating user discussions, and managing content. Significant attention is paid to the importance of security. The CD-ROM contains PHP 4, MySQL, and Apache source code and binaries. Annotation c. Book News, Inc., Portland, OR (
From The Critics
I like this book a great deal. Even after a fair amount of time with the previous edition I still find it useful ... Welling and Thomson have updated extensively and improved slightly a book that may well be the classic text on the topic.
Read More Show Less

Product Details

  • ISBN-13: 9780672325250
  • Publisher: Sams
  • Publication date: 2/13/2003
  • Series: Developer's Library
  • Edition description: Older Edition
  • Edition number: 2
  • Pages: 871
  • Product dimensions: 7.06 (w) x 9.18 (h) x 2.05 (d)

Meet the Author

Luke Welling and Laura Thomson are co-founders of Tangled Web Design and recently won the CCH Emerging Technology award for a site they built using PHP. Both are teachers at RMIT University in Melbourne, Australia, and have over five years of web design experience.
Read More Show Less

Read an Excerpt

Chapter 3: Using Arrays

This chapter shows you how to use an important programming construct—arrays. The variables that we looked at in the previous chapters are scalar variables, which store a single value. An array is a variable that stores a set or sequence of values. One array can have many elements. Each element can hold a single value, such as text or numbers, or another array. An array containing other arrays is known as a multidimensional array.

PHP supports both numerically indexed and associative arrays. You will probably be familiar with numerically indexed arrays if you've used a programming language, but unless you use PHP or Perl, you might not have seen associative arrays before. Associative arrays let you use more useful values as the index. Rather than each element having a numeric index, they can have words or other meaningful information.

We will continue developing the Bob's Auto parts example using arrays to work more easily with repetitive information such as customer orders. Likewise, we will write shorter, tidier code to do some of the things we did with files in the previous chapter.

Key topics covered in this chapter include

  • What is an array?

  • Numerically indexed arrays

  • Associative arrays

  • Multidimensional arrays

  • Sorting arrays

  • Further reading

What Is an Array?

We looked at scalar variables in Chapter 1, "PHP Crash Course." A scalar variable is a named location in which to store a value; similarly, an array is a named place to store a set of values, thereby allowing you to group common scalars.

Bob's product list will be the array for our example. In Figure 3.1, you can see a list of three products stored in an array format and one variable, called $products, which stores the three values. (We'll look at how to create a variable like this in a minute.)

Figure 3.1
Bob's products can be stored in an array.

After we have the information as an array, we can do a number of useful things with it. Using the looping constructs from Chapter 1, we can save work by performing the same actions on each value in the array. The whole set of information can be moved around as a single unit. This way, with a single line of code, all the values can be passed to a function. For example, we might want to sort the products alphabetically. To achieve this, we could pass the entire array to PHP's sort() function.

The values stored in an array are called the array elements. Each array element has an associated index (also called a key) that is used to access the element.

Arrays in most programming languages have numerical indexes that typically start from zero or one. PHP supports this type of array.

PHP also supports associative arrays, which will be familiar to Perl programmers. Associative arrays can have almost anything as the array indices, but typically use strings.

We will begin by looking at numerically indexed arrays.

Numerically Indexed Arrays

These arrays are supported in most programming languages. In PHP, the indices start at zero by default, although you can alter this.

Initializing Numerically Indexed Arrays

To create the array shown in Figure 3.1, use the following line of PHP code:

$products = array( "Tires", "Oil", "Spark Plugs" );

This will create an array called products containing the three values given—"Tires", "Oil", and "Spark Plugs". Note that, like echo, array() is actually a language construct rather than a function.

Depending on the contents you need in your array, you might not need to manually initialize them as in the preceding example.

If you have the data you need in another array, you can simply copy one array to another using the = operator.

If you want an ascending sequence of numbers stored in an array, you can use the range() function to automatically create the array for you. The following line of code will create an array called numbers with elements ranging from 1 to 10:

$numbers = range(1,10);

If you have the information stored in file on disk, you can load the array contents directly from the file. We'll look at this later in this chapter under the heading "Loading Arrays from Files."

If you have the data for your array stored in a database, you can load the array contents directly from the database. This is covered in Chapter 10, "Accessing Your MySQL Database from the Web with PHP."

You can also use various functions to extract part of an array or to reorder an array. We'll look at some of these functions later in this chapter, under the heading "Other Array Manipulations."

Accessing Array Contents

To access the contents of a variable, use its name. If the variable is an array, access the contents using the variable name and a key or index. The key or index indicates which stored values we access. The index is placed in square brackets after the name.

Type $products[0], $products[1], and $products[2] to use the contents of the products array.

Element zero is the first element in the array. This is the same numbering scheme as used in C, C++, Java, and a number of other languages, but it might take some getting used to if you are not familiar with it.

As with other variables, array elements contents are changed by using the = operator. The following line will replace the first element in the array "Tires" with "Fuses".

$products[0] = "Fuses";

The following line could be used to add a new element—"Fuse"—to the end of the array, giving us a total of four elements:

$products[3] = "Fuses";

To display the contents, we could type

echo "$products[0] $products[1] $products[2] $products[3]";

Like other PHP variables, arrays do not need to be initialized or created in advance. They are automatically created the first time you use them.

The following code will create the same $products array:

$products[0] = "Tires";
$products[1] = "Oil";
$products[2] = "Spark Plugs";

If $products does not already exist, the first line will create a new array with just one element. The subsequent lines add values to the array.

Using Loops to Access the Array

Because the array is indexed by a sequence of numbers, we can use a for loop to more easily display the contents:

for ( $i = 0; $i<3; $i++ )
 echo "$products[$i] ";

This loop will give similar output to the preceding code, but will require less typing than manually writing code to work with each element in a large array. The ability to use a simple loop to access each element is a nice feature of numerically indexed arrays. Associative arrays are not quite so easy to loop through, but do allow indexes to be meaningful.

Associative Arrays

In the products array, we allowed PHP to give each item the default index. This meant that the first item we added became item 0, the second item 1, and so on. PHP also supports associative arrays. In an associative array, we can associate any key or index we want with each value.

Initializing an Associative Array

The following code creates an associative array with product names as keys and prices as values.

$prices = array( "Tires"=>100, "Oil"=>10, "Spark Plugs"=>4 );

Accessing the Array Elements

Again, we access the contents using the variable name and a key, so we can access the information we have stored in the prices array as $prices[ "Tires" ], $prices[ "Oil" ], and $prices[ "Spark Plugs" ].

Like numerically indexed arrays, associative arrays can be created and initialized one element at a time.

The following code will create the same $prices array. Rather than creating an array with three elements, this version creates an array with only one element, and then adds two more.

$prices = array( "Tires"=>100 );
$prices["Oil"] = 10;
$prices["Spark Plugs"] = 4;

Here is another slightly different, but equivalent piece of code. In this version, we do not explicitly create an array at all. The array is created for us when we add the first element to it.

$prices["Tires"] = 100;
$prices["Oil"] = 10;
$prices["Spark Plugs"] = 4;

Using Loops with each() and list()

Because the indices in this associative array are not numbers, we cannot use a simple counter in a for loop to work with the array. The following code lists the contents of our $prices array:

while( $element = each( $prices ) )
 echo $element[ "key" ];
 echo " - ";
 echo $element[ "value" ];
 echo "<br>";

The output of this script fragment is shown in Figure 3.2.

Figure 3.2
An each statement can be used to loop through arrays.

In Chapter 1, we looked at while loops and the echo statement. The preceding code uses the each() function, which we have not used before. This function returns the current element in an array and makes the next element the current one. Because we are calling each() within a while loop, it returns every element in the array in turn and stops when the end of the array is reached.

In this code, the variable $element is an array. When we call each(), it gives us an array with four values and the four indexes to the array locations. The locations key and 0 contain the key of the current element, and the locations value and 1 contain the value of the current element. Although it makes no difference which you choose, we have chosen to use the named locations, rather than the numbered ones.

There is a more elegant and more common way of doing the same thing. The function list() can be used to split an array into a number of values. We can separate two of the values that the each() function gives us like this...

Read More Show Less

Table of Contents

I Using PHP
1 PHP Crash Course 11
2 Storing and Retrieving Data 51
3 Using Arrays 71
4 String Manipulation and Regular Expressions 95
5 Reusing Code and Writing Functions 117
6 Object-Oriented PHP 145
II Using MySQL
7 Designing Your Web Database 169
8 Creating Your Web Database 181
9 Working with Your MySQL Database 203
10 Accessing Your MySQL Database from the Web with PHP 223
11 Advanced MySQL 241
III E-commerce and Security
12 Running an E-Commerce Site 261
13 E-Commerce Security Issues 273
14 Implementing Authentication with PHP and MySQL 293
15 Implementing Secure Transactions with PHP and MySQL 315
IV Advanced PHP Techniques
16 Interacting with the File System and the Server 337
17 Using Network and Protocol Functions 357
18 Managing the Date and Time 379
19 Generating Images 387
20 Using Session Control in PHP 413
21 Other Useful Features 429
V Building Practical PHP and MySQL Projects
22 Using PHP and MySQL for Large Projects 439
23 Debugging 455
24 Building User Authentication and Personalization 473
25 Building a Shopping Cart 511
26 Building a Content Management System 555
27 Building a Web-Based Email Service 585
28 Building a Mailing List Manager 621
29 Building Web Forums 675
30 Generating Personalized Documents in Portable Document Format (PDF) 705
31 Connecting to Web Services with XML and SOAP 739
VI Appendixes
A Installing PHP and MySQL 789
B: Web Resources 813
Index 817
Read More Show Less

Customer Reviews

Average Rating 5
( 5 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 5 Customer Reviews
  • Anonymous

    Posted August 3, 2004

    Flawless book

    This book is probably the best technical book I ever read. Unlike other books, this actually teaches you how to use PHP and MYSQL in real world. Before this book, I hated programming and thought that it was so hard to learn. Know, I actually enjoy it because this book inspired me.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 12, 2004

    Worth Its Weight In Gold

    I've been trying to develop an interactive website for a few months now and never quite knew how to get started. At first, I started working with java, but got nowhere. Then I tried learning perl, but had no success. But within four days of purchasing this book, I had found the answers to all my questions. Not only is the material presented in the most straight forward fashion imaginable, but it provides an outstanding amount of example code that teaches you how to build everything from shopping carts to web forums. It is, by far, the best technical reference I have ever purchased.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 8, 2004


    I can consider this book as a source book of an open source technology...I do really like it. This book is for everybody who shares one thing in common which is love of programming and web developing...This book is dynamic and efficient enough to put you inside php world. I like also their other series like PostgreSQL, Cocoon and MySQL.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted February 29, 2004

    An excellent, in-depth book

    This book is an incredible resource for learning PHP. It starts off going through all the basics of PHP nice and thoroughly with useful examples. Then it gets into MySQL. Again, it goes through the basics of how to set up and use the database with great detail. Then, a whole unit devoted to E-Commerce and security. From there, it gets into some great advanced PHP techniques, such as interacting with files, creating and modifying images, using session control, and much more. Also, there is advanced information on MySQL. Much of the rest of the book shows how to use all the skills you just learned to create very useful web projects, such as a web-mail interface, a shopping cart, content management, user authentication, and more. All in all an extremely detailed, all-in-one book. Highly recommended.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted September 2, 2003

    This is the one

    Feel free to spend hundreds of dollars on many of the other fine PHP books out there, just like I did. But if you actually NEED to use PHP and only want one book, this is the one. This book is absolutely fantastic and it's only problem is that it may have too much information. I could see how it might be overwhelming to have it all in one place.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 5 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)