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.

9780672329166

Php And Mysql Web Development

by ;
  • ISBN13:

    9780672329166

  • ISBN10:

    0672329166

  • Edition: 4th
  • Format: Paperback
  • Copyright: 2008-10-01
  • Publisher: Addison-Wesley Professional
  • View Upgraded Edition
  • 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: $54.99

Summary

The definitive, best-selling book on combining these two open source tools to create dynamic Web sites - updated for PHP5.1 and MySQL 5.1

Author Biography

Lead Authors


Laura Thomson is a senior software engineer at Mozilla Corporation. She was formerly a principal at both OmniTI and Tangled Web Design, and she has worked for RMIT University and the Boston Consulting Group. She holds a Bachelor of Applied Science (Computer Science) degree and a Bachelor of Engineering (Computer Systems Engineering) degree with honors.

 

Luke Welling is a web architect at OmniTI and regularly speaks on open source and web development topics at conferences such as OSCON, ZendCon, MySQLUC, PHPCon, OSDC, and LinuxTag. Prior to joining OmniTI, he worked for the web analytics company Hitwise.com, at the database vendor MySQL AB, and as an independent consultant at Tangled Web Design. He has taught computer science at RMIT University in Melbourne, Australia, and holds a Bachelor of Applied Science (Computer Science) degree.

 

Contributing Authors


Julie C. Meloni is the technical director for i2i Interactive (www.i2ii.com), a multimedia company located in Los Altos, California. She has been developing web-based applications since the Web first saw the light of day and remembers the excitement surrounding the first GUI web browser. She has authored numerous books and articles on web-based programming languages and database topics, including the bestselling Sams Teach Yourself PHP, MySQL and Apache All in One.

 

Adam DeFields is a consultant specializing in web application development, project management, and instructional design. He lives in Grand Rapids, Michigan where he runs Emanation Systems, LLC, a company he founded in 2002. He has been involved with web development projects using several different technologies, but has developed a strong preference toward PHP/MySQL-based projects.

 

Marc Wandschneider is a freelance software developer, author, and speaker who travels the globe working on interesting projects. In recent years, a lot of his attention has been focused on writing robust and scalable web applications, and in 2005 he wrote a book called Core Web Application Programming with PHP and MySQL. He was was previously the main developer of the SWiK open source community site.

 

Table of Contents

Introductionp. 1
I Using PHP1 PHP Crash Coursep. 13
Before You Begin: Accessing PHPp. 14
Creating a Sample Application: Bob's Auto Partsp. 14
Creating the Order Formp. 14
Processing the Formp. 16
Embedding PHP in HTMLp. 17
PHP Tagsp. 18
PHP Statementsp. 19
Whitespacep. 20
Commentsp. 20
Adding Dynamic Contentp. 21
Calling Functionsp. 22
Using the date() Functionp. 22
Accessing Form Variablesp. 23
Short, Medium, and Long Variablesp. 23
String Concatenationp. 26
Variables and Literalsp. 27
Understanding Identifiersp. 28
Examining Variable Typesp. 29
PHP's Data Typesp. 29
Type Strengthp. 29
Type Castingp. 30
Variable Variablesp. 30
Declaring and Using Constantsp. 31
Understanding Variable Scopep. 31
Using Operatorsp. 32
Arithmetic Operatorsp. 33
String Operatorsp. 34
Assignment Operatorsp. 34
Comparison Operatorsp. 36
Logical Operatorsp. 38
Bitwise Operatorsp. 38
Other Operatorsp. 39
Working Out the Form Totalsp. 41
Understanding Precedence and Associativityp. 42
Using Variable Functionsp. 44
Testing and Setting Variable Typesp. 44
Testing Variable Statusp. 45
Reinterpreting Variablesp. 46
Making Decisions with Conditionalsp. 46
if Statementsp. 46
Code Blocksp. 47
else Statementsp. 47
elseif Statementsp. 48
switch Statementsp. 49
Comparing the Different Conditionalsp. 51
Repeating Actions Through Iterationp. 51
while Loopsp. 53
for and foreach Loopsp. 54
do...while Loopsp. 55
Breaking Out of a Control Structure or Scriptp. 56
Employing Alternative Control Structure Syntaxp. 56
Using declarep. 57
Next 572 Storing and Retrieving Datap. 59
Saving Data for Laterp. 59
Storing and Retrieving Bob's Ordersp. 60
Processing Filesp. 61
Opening a Filep. 61
Choosing File Modesp. 61
Using fopen() to Open a Filep. 62
Opening Files Through FTP or HTTPp. 64
Addressing Problems Opening Filesp. 65
Writing to a Filep. 67
Parameters for fwrite()p. 68
File Formatsp. 68
Closing a Filep. 69
Reading from a Filep. 71
Opening a File for Reading: fopen()p. 72
Knowing When to Stop: feof()p. 73
Reading a Line at a Time: fgets(), fgetss(), andfgetcsv()p. 73
Reading the Whole File: readfile(), fpassthru(), andfile()p. 74
Reading a Character: fgetc()p. 75
Reading an Arbitrary Length: fread()p. 75
Using Other Useful File Functionsp. 76
Checking Whether a File Is There: file_exists()p. 76
Determining How Big a File Is: filesize()p. 76
Deleting a File: unlink()p. 76
Navigating Inside a File: rewind(), fseek(), andftell()p. 76
Locking Filesp. 78
A Better Way: Database Management Systemsp. 79
Problems with Using Flat Filesp. 79
How RDBMSs Solve These Problemsp. 80
Further Readingp. 80
Next 803 Using Arraysp. 81
What Is an Array?p. 81
Numerically Indexed Arraysp. 82
Initializing Numerically Indexed Arraysp. 82
Accessing Array Contentsp. 83
Using Loops to Access the Arrayp. 84
Arrays with Different Indicesp. 85
Initializing an Arrayp. 85
Accessing the Array Elementsp. 85
Using Loopsp. 85
Array Operatorsp. 87
Multidimensional Arraysp. 88
Sorting Arraysp. 92
Using sort()p. 92
Using asort() and ksort() to Sort Arraysp. 93
Sorting in Reversep. 93
Sorting Multidimensional Arraysp. 93
User-Defined Sortsp. 93
Reverse User Sortsp. 95
Reordering Arraysp. 96
Using shuffle()p. 96
Using array_reverse()p. 97
Loading Arrays from Filesp. 98
Performing Other Array Manipulationsp. 102
Navigating Within an Array: each(), current(), reset(), end(), next(), pos(), and prev()p. 102
Applying Any Function to Each Element in anArray: array_walk()p. 103
Counting Elements in an
Table of Contents provided by Publisher. All Rights Reserved.

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.

Excerpts

Introduction Introduction Welcome to PHP and MySQL Web Development. Within its pages, you will find distilled knowledge from our experiences using PHP and MySQL, two of the hottest web development tools around. In this introduction, we cover Why you should read this book What you will be able to achieve using this book What PHP and MySQL are and why they're great What's changed in the latest versions of PHP and MySQL How this book is organized Let's get started. Why You Should Read This Book This book will teach you how to create interactive websites from the simplest order form through to complex, secure e-commerce sites or interactive Web 2.0 sites. What's more, you'll learn how to do it using open source technologies. This book is aimed at readers who already know at least the basics of HTML and have done some programming in a modern programming language before but have not necessarily programmed for the Internet or used a relational database. If you are a beginning programmer, you should still find this book useful, but digesting it might take a little longer. We've tried not to leave out any basic concepts, but we do cover them at speed. The typical readers of this book want to master PHP and MySQL for the purpose of building a large or commercial website. You might already be working in another web development language; if so, this book should get you up to speed quickly. We wrote the first edition of this book because we were tired of finding PHP books that were basically function references. These books are useful, but they don't help when your boss or client has said, "Go build me a shopping cart." In this book, we have done our best to make every example useful. You can use many of the code samples directly in your website, and you can use many others with only minor modifications. What You Will Learn from This Book Reading this book will enable you to build real-world, dynamic websites. If you've built websites using plain HTML, you realize the limitations of this approach. Static content from a pure HTML website is just that--static. It stays the same unless you physically update it. Your users can't interact with the site in any meaningful fashion. Using a language such as PHP and a database such as MySQL allows you to make your sites dynamic: to have them be customizable and contain real-time information. We have deliberately focused this book on real-world applications, even in the introductory chapters. We begin by looking at a simple online ordering system and work our way through the various parts of PHP and MySQL. We then discuss aspects of electronic commerce and security as they relate to building a real-world website and show you how to implement these aspects in PHP and MySQL. In the final part of this book, we describe how to approach real-world projects and take you through the design, planning, and building of the following projects: User authentication and personalization Shopping carts Web-based email Mailing list managers Web forums PDF document generation Web services with XML and SOAP Web 2.0 application with Ajax You should be able to use any of these projects as is, or you can modify them to suit your needs. We chose them because we believe they represent some the most common web-based applications built by programmers. If your needs are different, this book should help you along the way to achieving your goals. What Is PHP? PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the web server and generates HTML or other output that the visitor will see. PHP was conceived in 1994 and was originally the work of one man, Rasmus Lerdorf. It was adopted by other talented people and has gone through four major rewrites to bring us the broad, mature product we see today. As of November 2007, it was installed on more than 21 million domains worldwide, and this number is growing rapidly. You can see the current number athttp://www.php.net/usage.php. PHP is an Open Source project, which means you have access to the source code and can use, alter, and redistribute it all without charge. PHP originally stood for Personal Home Pagebut was changed in line with the GNU recursive naming convention (GNU = Gnu's Not Unix) and now stands for PHP Hypertext Preprocessor. The current major version of PHP is 5. This version saw a complete rewrite of the underlying Zend engine and some major improvements to the language. The home page for PHP is available athttp://www.php.net. The home page for Zend Technologies ishttp://www.zend.com. What Is MySQL? MySQL (pronounced My-Ess-Que-Ell) is a very fast, robust, relational database management system (RDBMS). A database enables you to efficiently store, search, sort, and retrieve data. The MySQL server controls access to your data to ensure that multiple users can work with it concurrently, to provide fast access to it, and to ensure that only authorized users can obtain access. Hence, MySQL is a multiuser, multithreaded server. It uses Structured Query Language (SQL), the standard database query language. MySQL has been publicly available since 1996 but has a development history going back to 1979. It is the world's most popular open source database and has won the Linux Journal Readers' Choice Award on a number of occasions. MySQL is available under a dual licensing scheme. You can use it under an open source license (the GPL) free as long as you are willing to meet the terms of that license. If you want to distribute a non-GPL application including MySQL, you can buy a commercial license instead. Why Use PHP and MySQL? When setting out to build a website, you could use many different products. You need to choose the following: Hardware for the web server An operating system Web server software A database management system A programming or scripting language Some of these choices are dependent on the others. For example, not all operating systems run on all hardware, not all web servers support all programming languages, and so on. In this book, we do not pay much attention to hardware, operating systems, or web server software. We don't need to. One of the best features of both PHP and MySQL is that they work with any major operating system and many of the minor ones. The majority of PHP code can be written to be portable between operating systems and web servers. There are some PHP functions that specifically relate to the filesystem that are operating system dependent, but these are clearly marked as such in the manual and in this book. Whatever hardware, operating system, and web server you choose, we believe you should seriously consider using PHP and MySQL. Some of PHP's Strengths Some of PHP's main competitors are Perl, Microsoft ASP.NET, Ruby (on Rails or otherwise), JavaServer Pages (JSP), and ColdFusion. In comparison to these products, PHP has many strengths, including the following: Performance Scalability In

Rewards Program