Sams Teach Yourself PHP, MySQL and Apache All in One
Julie C. Meloni
800 East 96th Street, Indianapolis, Indiana, 46240 USA
Sams Teach Yourself PHP, MySQLand Apache All in One
Copyright 2012 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
ISBN-13: 978-0-672-33543-3
ISBN-10: 0-672-33543-3
Library of Congress Cataloging-in-Publication Data
Meloni, Julie C.
Sams teach yourself PHP, MySQL and Apache : all in one / Julie C.
Meloni.
p. cm.
Includes index.
ISBN-13: 978-0-672-33543-3 (pbk. w/cd)
ISBN-10: 0-672-33543-3
1. Web site development. 2. PHP (Computer program language) 3.
Apache (Computer file : Apache Group) 4. MySQL (Electronic resource)
I. Title.
TK5105.888.M45 2012
005.13--dc23
2012016353
Printed in the United States of America
First Printing May 2012
Acquisitions Editor
Mark Taber
Development Editor
Songlin Qiu
Managing Editor
Sandra Schroeder
Project Editor
Mandie Frank
Copy Editor
Keith Cline
Indexer
Heather McNeill
Proofreader
Paula Lowell
Technical Editor
Timothy Boronczyk
Publishing Coordinator
Vanessa Evans
Media Producer
Dan Scherf
Designer
Gary Adair
Compositor
Studio Galou, LLC
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact
U.S. Corporate and Government Sales
1-800-382-3419
For sales outside of the U.S., please contact
International Sales
Table of Contents
About the Author
Julie C. Meloni is a technical consultant who has been developing web-based applications since the Web first saw the light of day. She has authored numerous books and articles on web-based programming and scripting languages and database topics, and you can find translations of her work in 18 different languages. She blogs at thickbook.com and nerdtripping.comthe latter reserved for tips and tricks for traveling while nerdy.
Acknowledgments
The Apache Software Foundation, the PHP Group, and MySQL AB deserve much more recognition than they ever get for creating these super products that drive the vast majority of the Web.
Although this book is several editions removed from the original text by Daniel Lopez (author of Sams Teach Yourself Apache 2 in 24 Hours) and Matt Zandstra (author of Sams Teach Yourself PHP in 24 Hours), this book would not exist without their work oh so many years ago.
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what were doing right, what we could do better, what areas youd like to see us publish in, and any other words of wisdom youre willing to pass our way.
You can email or write directly to let us know what you did or didnt like about this bookas well as what we can do to make our books stronger.
Please note that we cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail we receive, we might not be able to reply to every message.
When you write, please be sure to include this books title and author as well as your name and phone number or email address.
E-mail:
Mail: Reader Feedback
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Reader Services
Visit our website and register this book at informit.com/register for convenient access to any updates, downloads, or errata that might be available for this book.
Introduction
Welcome to Sams Teach Yourself PHP, MySQL, and Apache All in One, Fifth Edition. Im happy to report that the PHP language and its community of developers and users continues to grow every dayhence the need for a refresh of this book.
Since the previous edition of this book, the end of life of PHP 4 finally set in; with the help of a GoPHP5 initiative, web hosting providers and application developers migrated their services and code away from PHP 4specific features and coding practices and into the world of PHP 5full of speed and an even greater feature set. As with the previous edition, all the code in this edition is based on the latest version of PHP available at the time of this writing (5.4.0, in this case).
Some of you might have heard of PHP 6 or have seen books touting PHP 6 as the core language used. Well, a version of the language called PHP 6 never materializedthe functionality planned for a version 6 release was added to PHP 5.3 and PHP 5.4. So, have no fear; youre not missing anything if you hear PHP 6 and cannot find anything about it online or at the PHP.net website.
Over the course of this book, you learn the concepts necessary for configuring and managing the Apache web server, the basics of programming in PHP, and the methods for using and administering the MySQL relational database system. The overall goal of the book is to provide you with the foundation you need to understand how seamlessly these technologies integrate with one another and to give you practical knowledge of how to integrate them into functioning websites and web applications. This book should be a first stepnot your only stepto more advanced site development.
Who Should Read This Book?
This book is geared toward individuals who possess a general understanding of the concepts of working in a web-based development environment, be it Linux/UNIX, Windows, or Mac OS X. Installation and configuration instructions assume that you have familiarity with your operating system and the basic methods of building (on Linux/UNIX systems) or installing (on Windows and Mac OS X systems) software.
The lessons that delve into programming with PHP assume no previous knowledge of the language. However, if you have experience with other programming languages, such as ASP (Active Server Pages), JSP (JavaServer Pages), Ruby, or Perl, you will find the going much easier because of your familiarity with such programming elements as variables, control structures, functions, objects, and the like. Similarly, if you have worked with other databases, such as Oracle or Microsoft SQL Server, you already possess a solid foundation for working through the MySQL-related lessons.