PHP & MySQL

2y ago
78 Views
4 Downloads
4.84 MB
674 Pages
Last View : 27d ago
Last Download : 1y ago
Upload by : Ronan Orellana
Transcription

PHP & MySQL Web DevelopmentALL-IN-ONE DESK REFERENCEFORDUMmIES‰by Janet Valade with Tricia Balladand Bill Ballad

PHP & MySQL Web DevelopmentALL-IN-ONE DESK REFERENCEFORDUMmIES‰

PHP & MySQL Web DevelopmentALL-IN-ONE DESK REFERENCEFORDUMmIES‰by Janet Valade with Tricia Balladand Bill Ballad

PHP & MySQL Web Development All-in-One Desk Reference For Dummies Published byWiley Publishing, Inc.111 River StreetHoboken, NJ 07030-5774www.wiley.comCopyright 2008 by Wiley Publishing, Inc., Indianapolis, IndianaPublished by Wiley Publishing, Inc., Indianapolis, IndianaPublished simultaneously in CanadaNo part of this publication may be reproduced, stored in a retrieval system or transmitted in any form orby 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 writtenpermission of the Publisher, or authorization through payment of the appropriate per-copy fee to theCopyright 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 Legal Department, Wiley Publishing,Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online athttp://www.wiley.com/go/permissions.Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for theRest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related tradedress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the UnitedStates and other countries, and may not be used without written permission. MySQL is a registered trademark of MySQL Limited AB Company. 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 REPRESENTATIONSOR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK ANDSPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR APARTICULAR 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 ISSOLD 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 LIABLEFOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THISWORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THEAUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE ORRECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED INTHIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN ITIS READ. FULFILLMENT OF EACH COUPON OFFER IS THE SOLE RESPONSIBILITY OF THE OFFEROR.For general information on our other products and services, please contact our Customer CareDepartment within the U.S. at 800-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 maynot be available in electronic books.Library of Congress Control Number: 2007943295ISBN: 978-0-470-16777-9Manufactured in the United States of America10 9 8 7 6 5 4 3 2 1

About the AuthorJanet Valade is the author of PHP &MySQL For Dummies, which is in its thirdedition. She has also written PHP & MySQL Everyday Apps For Dummies andPHP & MySQL: Your visual blueprint for creating dynamic, database-driven Websites. In addition, Janet is the author of Spring into Linux and a co-author ofMastering Visually Dreamweaver CS3 and Flash CS3 Professional.Janet has 20 years of experience in the computing field. Most recently, sheworked as a Web designer and programmer in an engineering firm for fouryears. Prior to that, Janet worked for 13 years in a university environment,where she was a systems analyst. During her tenure, she supervised theinstallation and operation of computing resources, designed and developeda data archive, supported faculty and students in their computer usage,wrote numerous technical papers, and developed and presented seminarson a variety of technology topics.

DedicationThis book is dedicated to everyone who finds it useful.Author’s AcknowledgmentsFirst, I wish to express my appreciation to the entire open source community.Without those who give their time and talent, there would be no cool PHPand MySQL for me to write about. Furthermore, I never would have learnedthis software without the lists where people generously spend their timeanswering foolish questions from beginners.I want to thank my mother for passing on a writing gene, along with manyother things. And my children always for everything.And, of course, I want to thank the professionals who make it all possible.Without my agent and the people at Wiley Publishing, Inc., this book wouldnot exist. Because they all do their jobs so well, I can contribute my part tothis joint project.

Publisher’s AcknowledgmentsWe’re proud of this book; please send us your comments through our online registration formlocated at www.dummies.com/register/.Some of the people who helped bring this book to market include the following:Acquisitions, Editorial, andMedia DevelopmentComposition ServicesProject Editor: Jean NelsonAcquisitions Editor: Kyle LooperCopy Editor: Virginia SandersTechnical Editor: Ryan LoweProject Coordinator: Erin SmithLayout and Graphics: Claudia Bell, Carl Byers,Joyce Haughey, Melissa K. Jester,Barbara Moore, Ronald Terry,Christine WilliamsEditorial Manager: Kevin KirschnerProofreaders: John Greenough, Caitie Kelly,Christine SabooniMedia Development Project Manager:Laura Moss-Hollister OR Laura AtkinsonIndexer: Silvoskey Indexing ServicesMedia Development Assistant Producer:Angela Denny, Josh Frank, Kate Jenkins,OR Kit MaloneSpecial Help: Susan Christopherson,Kelly Ewing, and Laura K. MillerEditorial Assistant: Amanda FoxworthSr. Editorial Assistant: Cherie CaseCartoons: Rich Tennant(www.the5thwave.com)Publishing and Editorial for Technology DummiesRichard Swadley, Vice President and Executive Group PublisherAndy Cummings, Vice President and PublisherMary Bednarek, Executive Acquisitions DirectorMary C. Corder, Editorial DirectorPublishing for Consumer DummiesDiane Graves Steele, Vice President and PublisherJoyce Pepple, Acquisitions DirectorComposition ServicesGerry Fahey, Vice President of Production ServicesDebbie Stailey, Director of Composition Services

Contents at a GlanceIntroduction .1Book I: Setting Up Your Environment .7Chapter 1: Setting Up Your Web Environment.9Chapter 2: Installing PHP.21Chapter 3: Setting Up the MySQL Environment .47Chapter 4: Installing a Web Server .73Chapter 5: Setting Up Your Web Development Environmentwith the XAMPP Package .87Book II: PHP Programming.101Chapter 1: PHP Basics.103Chapter 2: Building PHP Scripts .151Chapter 3: PHP and Your Operating System .197Chapter 4: Object-Oriented Programming .229Book III: Using MySQL .257Chapter 1: Introducing MySQL .259Chapter 2: Administering MySQL .269Chapter 3: Designing and Building a Database.295Chapter 4: Using the Database .319Chapter 5: Communicating with the Database from PHP Scripts .343Book IV: Security.357Chapter 1: General Security Considerations.359Chapter 2: An Overview of Authentication and Encryption .373Chapter 3: Creating a Secure Environment .383Chapter 4: Programming Securely in PHP .397Chapter 5: Programming Secure E-Commerce Applications.409Book V: PHP Extensions .421Chapter 1: Introduction to Extensions .423Chapter 2: Using PEAR.429Chapter 3: Using the XML Extension .441Chapter 4: Manipulating Images with the GD Extension .449Chapter 5: Mail Extensions.459

Book VI: PHP Web Applications.467Chapter 1: Building and Processing Dynamic Forms.469Chapter 2: Making Information Available on Multiple Web Pages .511Chapter 3: Building a Login Application.533Chapter 4: Building an Online Catalog.555Chapter 5: Building a Shopping Cart.571Index .617

Table of ContentsIntroduction.1About This Book.1Conventions Used in This Book .2What You’re Not to Read.3Foolish Assumptions .4How This Book Is Organized.4Book I: Setting Up Your Environment .4Book II: PHP Programming .5Book III: Using MySQL.5Book IV: Security .5Book V: PHP Extensions .5Book VI: PHP Web Applications.5Companion Web site .5Icons Used in This Book.6Getting Started .6Book I: Setting Up Your Environment .7Chapter 1: Setting Up Your Web Environment . . . . . . . . . . . . . . . . . . . . .9The Required Tools.10Choosing a Host for Your Web Site .10A company Web site.11An educational institution.12A Web-hosting company.13Using a hosted Web site .15Choosing Your Development Environment.16Setting Up Your Local Computer for Development .17Installing the Web server.17Installing MySQL.18Installing PHP.18Getting help with your software.19Keeping Up with PHP and MySQL Changes .19Chapter 2: Installing PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21Checking the PHP Installation .22Obtaining PHP .

Janet Valade is the author of PHP &MySQL For Dummies, which is in its third edition. She has also written PHP & MySQL Everyday Apps For Dummies and PHP & MySQL: Your visual blueprint for creating dynamic, database-driven Web sites. In addition, Janet is the author of Spring into Linux and a co-author of

Related Documents:

MySQL PHP Syntax MySQL works very well in combination of various programming languages like PERL, C, C , JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities. PHP provides various functions to access MySQL database and to manipulate data records inside MySQL database.

MySQL is no longer enabled by default, so the php_mysql.dllDLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dllis included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATHon Windows" for .

Section 4: PHP and MySQL - The Structured Repository 4.1 PHP MySQL Connectivity 4.2 Integrating Web Forms and Database 4.3 Using PHP’s MySQL Extension 4.4 Using PHP’s PDO Extension Section 5: Learn More Advanced Techniques in PHP 5.1 Introduction to Object Oriented Programming 5.2 Classes and Objects

PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side Where to Start? To get access to a web server with PHP support, you can: Install Apache (or IIS) on your own server, install PHP, and MySQL Or find a web hosting plan with PHP and

MySQL for Excel is a 32-bit add-in for Microsoft Excel, which you can install and run on Microsoft Windows. MySQL for Excel is not compatible with Linux or macOS. MySQL for Excel can interact with MySQL Workbench to simplify the management of MySQL connections when both MySQL client tools are installed.

Lifetime Support Oracle Premier Support Oracle Product Certifications MySQL Enterprise High Availability MySQL Enterprise Security MySQL Enterprise Scalability MySQL Enterprise Backup MySQL Enterprise Monitor/Query Analyzer MySQL Workbench MySQL Enterprise Edition. 11 MySQL Database

uqc103s/UFCE47-20-1 PHP-mySQL 7 Why PHP and mySQL „ MySQL is a key part of LAMP (Linux, Apache, MySQL, PHP / Perl / Python), a fast growing open source enterprise software stack. More and more companies are using LAMP as an alternative to expensive proprietary software stacks because of its lower cost and freedom from lock-in.

This tutorial focuses heavily on using MySQL in a PHP environment. It is aimed at teaching those who have web hosts with PHP and MySQL already installed. If you are unsure, please contact your web host. MySQL Setup Guide The easiest way to experiment with MySQL and PHP is to p