Learning PHP, MySQL, and JavaScript , the image of sugar gliders, and related trade dress are trademarks of O’Reilly Media, Inc.. Many of the designations used by manufacturers and selle[r]
(1)(2)(3)Learning PHP, MySQL, and JavaScript
Robin Nixon
(4)by Robin Nixon
Copyright © 2009 Robin Nixon All rights reserved Printed in the United States of America
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safaribooksonline.com) For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com
Editor: Andy Oram
Production Editor: Sumita Mukherji Copyeditor: Nancy Kotary Proofreader: Kiel Van Horn
Indexer: Ellen Troutman Zaig Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Printing History:
July 2009: First Edition
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc Learning PHP, MySQL, and JavaScript, the image of sugar gliders, and related trade dress are trademarks of O’Reilly Media, Inc
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps
While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information con-tained herein
TM
This book uses RepKover™, a durable and flexible lay-flat binding ISBN: 978-0-596-15713-5
(5)Table of Contents
Preface xiii 1 Introduction to Dynamic Web Content 1
HTTP and HTML: Berners-Lee’s Basics The Request/Response Procedure The Benefits of PHP, MySQL, and JavaScript
Using PHP
Using MySQL
Using JavaScript
The Apache Web Server
About Open Source
Bringing It All Together
Test Your Knowledge: Questions 11
2 Setting Up a Development Server 13
What Is a WAMP, MAMP, or LAMP? 13 Installing a WAMP on Windows 14 Overcoming Installation Problems 14
Testing the Installation 16
Alternative WAMPs 18
Installing a MAMP on Mac OS X 19
Some Final Tweaking 24
Other Alternatives 25
Installing a LAMP on Linux 25
Working Remotely 26
Logging In 27
Using FTP 27
Using a Program Editor 28
Using an IDE 30
Test Your Knowledge: Questions 32
(6)Robin Nixon has worked with and written about computers since the early 1980s (his first computer was a Tandy TRS 80 Model with a massive KB of RAM!) During this time he has written in excess of 500 articles for many of the UK’s top computer magazines Learning PHP, MySQL, and JavaScript is his third book
Robin started his computing career in the Cheshire homes for disabled people, where he was responsible for setting up computer rooms in a number of residential homes, and for evaluating and tailoring hardware and software so that disabled people could use the new technology—sometimes by means of only a single switch operated by mouth or finger
After writing articles for computer magazines about his work with disabled people, he eventually worked full time for one of the country’s main IT magazine publishers, where he held several roles including editorial, promotions, and cover disc editing
With the dawn of the Internet in the 1990s, Robin branched out into developing web-sites One of these presented the world’s first radio station licensed by the music copy-right holders, and was featured in several news reports on TV and radio networks in the United Kingdom In order to enable people to continue to surf while listening, Robin also developed the first known pop-up windows
Robin lives on the southeast coast of England with his wife Julie, a trained nurse, and five children, where he also finds time to foster three disabled children, as well as working full time from home as a technical author
Colophon
The animals on the cover of Learning PHP, MySQL, and JavaScript are sugar gliders
(Petaurus breviceps) Sugar gliders are small, gray-furred creatures that grow to an adult
length of six to seven-and-a-half inches Their tails, which are distinguished by a black tip, are usually as long as their bodies Membranes extend between their wrists and ankles and provide an aerodynamic surface that helps them glide between trees Sugar gliders are native to Australia and Tasmania They prefer to live in the hollow parts of eucalyptus and other types of large trees with several other adult sugar gliders and their own children
(7)Sugar gliders make popular pets because of their inquisitive, playful natures, and be-cause many think they are cute But there are disadvantages to keeping sugar gliders as pets: as they are exotic animals, sugar gliders need specialized, complicated diets con-sisting of items such as crickets, a variety of fruits and vegetables, and mealworms; healthy housing requires a cage or space no less than the size of an aviary; their dis-tinctive scents can be bothersome to humans; as they are nocturnal creatures, they will bark, hiss, run, and glide all night long; it’s not uncommon for them to extricate their bowels while playing or eating; and in some states and countries, it is illegal to own sugar gliders as household pets
(