PHP & MySQL For Dummies
by Janet Valade
PHP & MySQL For Dummies, 4th Edition
Published by
Wiley Publishing, Inc.
111 River St.
Hoboken, NJ 07030-5774
www.wiley.com
Copyright 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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 Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, Making Everything Easier, 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. 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.
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.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
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: 2009940274
ISBN: 978-0-470-52758-0
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
About the Author
Janet Valade is the author of PHP & MySQL Web Development All-in-One Desk Reference For Dummies, PHP 5 For Dummies, PHP & MySQL Everyday Apps For Dummies, and PHP & MySQL: Your visual blueprint for creating dynamic, database-driven Web sites, as well as the first, second, and third editions of this book. In addition, Janet is the author of Spring into Linux and a coauthor of Mastering Visually Dreamweaver 8 and Flash 8.
Janet has twenty years of experience in the computing field. Most recently, she worked as a Web designer and programmer in an engineering firm for four years. Before that, Janet worked for thirteen years in a university environment, where she was a systems analyst. During her tenure, she supervised the installation and operation of computing resources, designed and developed a data archive, supported faculty and students in their computer usage, wrote numerous technical papers, and developed and presented seminars on a variety of technology topics.
To keep in touch, see janetvalade.com.
Authors Acknowledgments
First, I want to express my appreciation to the entire open source community. Without those who give their time and talent, there would be no cool PHP and MySQL for me to write about. Furthermore, I never would have learned this software without the lists, where people generously spend their time answering foolish questions from beginners.
I want to thank my mother for passing on a writing gene, along with many other things. And my children always for everything. My thanks to my friends Art, Dick, and Marge for responding to my last-minute call for help. I particularly want to thank Sammy, Dude, Spike, Lucky, Upanishad, Sadie, and E.B. for their important contributions.
And, of course, I want to thank the professionals who make it all possible. Without the people at Wiley, this book would not exist. Because they all do their jobs so well, I can contribute my part to this joint project.
Publishers Acknowledgments
Were proud of this book; please send us your comments through our online registration form located at http://dummies.custhelp.com. For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media Development
Project Editor: Rebecca Senninger (Previous Edition: Pat OBrien)
Acquisitions Editor: Kyle Looper
Copy Editor: Virginia Sanders
Technical Editor: John Gosney
Editorial Manager: Leah Cameron
Editorial Assistant: Amanda Foxworth
Sr. Editorial Assistant: Cherie Case
Cartoons: Rich Tennant (www.the5thwave.com)
Composition Services
Project Coordinator: Kristie Rees
Layout and Graphics: Melissa K. Jester, Christine Williams
Proofreader: Toni Settle
Indexer: BIM Indexing & Proofreading
Publishing and Editorial for Technology Dummies
Richard Swadley , Vice President and Executive Group Publisher
Andy Cummings , Vice President and Publisher
Mary Bednarek , Executive Acquisitions Director
Mary C. Corder , Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele , Vice President and Publisher
Composition Services
Debbie Stailey , Director of Composition Services
Introduction
W elcome to the exciting world of Web database applications. This book provides the basic techniques to build any Web database application, but I certainly recommend that you start with a simple one. In this book, I develop two sample applications, both chosen to represent two types of applications frequently encountered on the Web: product catalogs and customer- or member-only sites that require the user to register and log in with a password. The sample applications are complicated enough to require more than one program and to use a variety of data and data manipulation techniques, yet simple enough to be easily understood and adapted to a variety of Web sites. After you master the simple applications, you can expand the basic design to include all the functionality that you can think of.