PHP 6/Mysql Programming for the Absolute Beginner

PHP 6/Mysql Programming for the Absolute Beginner

PHP 6/MySQL® Programming for the Absolute Beginner Andy Harris Course Technology PTR A part of Cengage Learning Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States PHP 6/MySQL Programming for the © 2009 Course Technology, a part of Cengage Learning. Absolute Beginner: Andy Harris ALL RIGHTS RESERVED. No part of this work covered by the copyright Publisher and General Manager, Course herein may be reproduced, transmitted, stored, or used in any form or by Technology PTR: Stacy L. Hiquet any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, Associate Director of Marketing: information networks, or information storage and retrieval systems, except Sarah Panella as permitted under Section 107 or 108 of the 1976 United States Copyright Manager of Editorial Services: Act, without the prior written permission of the publisher. Heather Talbot Marketing Manager: Mark Hughes For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706 Acquisitions Editor: Mitzi Koontz For permission to use material from this text or product, submit all Project Editor: Jenny Davidson requests online at cengage.com/permissions Further permissions questions can be emailed to [email protected] Technical Reviewer: Matt Telles PTR Editorial Services Coordinator: Erin Johnson PHP is a copyright of the PHP Group. MySQL is a registered trademark of MySQL AB in the United States, the European Union and other countries. Interior Layout Tech: Value Chain Firefox and Maguma Open Studio are registered trademarks of the Mozilla Foundation. HTML Validator is a registered trademark of the Massachusetts Cover Designer: Mike Tanamachi Institute of Technology, European Research Consortium for Informatics and CD-ROM Producer: Brandon Penticuff Mathematics, or Keio University on behalf of the World Wide Web Consor- tium. Aptana is a registered trademark of Aptana, Inc. Indexer: Larry Sweazy All other trademarks are the property of their respective owners. Proofreader: Sara Gullion Library of Congress Control Number: 2008928831 ISBN-13: 978-1-59863-798-4 ISBN-10: 1-59863-798-3 eISBN-10: 1-59863-826-2 Course Technology 25 Thomson Place Boston, MA 02210 USA Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at: international.cengage.com/region Cengage Learning products are represented in Canada by Nelson Education, Ltd. For your lifelong learning solutions, visit courseptr.com Visit our corporate website at cengage.com Printed in Canada 1 2 3 4 5 6 7 11 10 09 To Heather, Elizabeth, Matthew, Jacob, and Benjamin, and to all those who have called me Teacher. ACKNOWLEDGMENTS irst, I thank my Lord and Savior Jesus Christ. FHeather, you always work harder on these books than I do. Thank you for your love and your support. Thank you Elizabeth, Matthew, Jacob, and Benjamin for understanding why Dad was typing all the time. Thanks to the Open Source community for creating great free software like PHP and MySQL. Thank you, Stacy Hiquet, for your continued support and encouragement on this and other projects. Thanks to Mitzi Koontz, for seeing this project through, and to Jenny Davidson for your work as the project editor. Special thanks to Matt Telles for the outstanding technical edit. You made the book far better than it would have been before. Thanks to all who worked on the previous two editions. Your hard work was the foundation for something that might be even better. Thank you to the many members of the Course Technology PTR team who worked on this book. A huge thanks goes to my students throughout the years and the many people who sent in comments and advice from the first two editions. Thank you for being patient with my manuscript, for helping me spot many errors, and for providing invaluable advice. I learned as much from you as you did from me. ABOUT THE AUTHOR ndy Harris began his teaching career as a high-school special education Ateacher. During that time, he taught himself enough computing to do part- time computer consulting and database work. He began teaching comput- ing at the university level in the late 1980s as a part-time job. Since 1995 he has been a full-time lecturer in the Computer Science Department of Indiana University/Purdue University–Indianapolis, where he serves as a senior lecturer and teaches classes in several programming languages. His primary interests are web development, PHP, Java, game programming, virtual reality, portable devices, and streaming media. He has written numerous books on these and other tech- nology topics. This page intentionally left blank Table of Contents Chapter 1 Exploring the Environment..................................... 1 Programming on the Web Server...................................................................................... 3 Installing PHP and Apache ......................................................................................... 4 Using an Existing Server.............................................................................................. 4 Installing Your Own Development Environment................................................. 5 Installing with XAMPP................................................................................................. 7 Starting Your Server ..................................................................................................... 8 Checking Your Security Settings............................................................................... 9 Configuring Apache.................................................................................................... 10 Running Your Local Server................................................................................................ 11 Adding PHP to Your Pages......................................................................................... 11 Examining the Results............................................................................................... 12 Display Errors............................................................................................................... 16 Windows Extensions .................................................................................................. 17 Changes in PHP 6......................................................................................................... 19 Safe Mode....................................................................................................................... 19 Register Globals ........................................................................................................... 19 Creating the Tip of the Day Program............................................................................. 19 Summary................................................................................................................................ 20 Chapter 2 Using Variables and Input...................................... 21 Introducing the Story Program........................................................................................ 21 Using Variables in Your Scripts........................................................................................ 23 Introducing the Hi Jacob Program ......................................................................... 23 Creating a String Variable................................................................................................. 25 Naming Your Variables.............................................................................................. 25 Assigning a Value to a Variable ............................................................................... 25 Printing a Variable’s Value ....................................................................................... 26 Using Variables for More Complex Pages...................................................................... 28 Building the Row Your Boat Page ........................................................................... 28 Creating Multi-Line Strings ...................................................................................... 30 Working with Numeric Variables.................................................................................... 31 Making the ThreePlusFive Program ....................................................................... 31 viii PHP 6/MySQL Programming for the Absolute Beginner Assigning Numeric Values........................................................................................ 33 Using Mathematical Operators................................................................................ 33 Creating a Form to Ask a Question................................................................................. 34 Building an HTML Page with a Form ..................................................................... 35 Setting the Action Attribute to a Script File ........................................................ 36 Writing a Script to Retrieve the Data .................................................................... 37 Sending Data without a Form.......................................................................................... 39 Understanding the get Method ..............................................................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    513 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us