phpmysql4pdf.pdf

(7518 KB) Pobierz
Pantone:
CMYK:
DATABASE
DRIVEN WEB SITE
PANTONE Orange 021 C
CMYK O, 53, 100, 0
Black 50%
PANTONE 2955 C
CMYK 100, 45, 0, 37
Black 100%
BUILD YOUR OWN
Grey scale
USING PHP & MYSQL
BY
KEVIN YANK
4
TH EDITION
LEARNING PHP & MYSQL HAS NEVER BEEN SO EASY!
Summary of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
1. Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Introducing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3. Introducing PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4. Publishing MySQL Data on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
5. Relational Database Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6. Structured PHP Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
7. A Content Management System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
8. Content Formatting with Regular Expressions . . . . . . . . . . . . . . . . . . . . . . 241
9. Cookies, Sessions, and Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
10. MySQL Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
11. Advanced SQL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
12. Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
A. MySQL Syntax Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
B. MySQL Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
C. MySQL Column Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
D. PHP Functions for Working with MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
BUILD YOUR OWN
DATABASE DRIVEN WEB
SITE USING PHP & MYSQL
BY
KEVIN YANK
4TH EDITION
iv
Build Your Own Database Driven Web Site Using PHP & MySQL
by Kevin Yank
Copyright
©
2009 SitePoint Pty. Ltd.
Managing Editor:
Chris Wyness
Technical Editor:
Andrew Tetlaw
Indexer:
Russell Brooks
Printing History:
1st Ed. Aug. 2001, 2nd Ed. Feb. 2003,
3rd Ed. Oct. 2004
Fourth Edition: July 2009
Latest Update:
July 2009
Editor:
Kelly Steele
Cover Design:
Alex Walker
Notice of Rights
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embodied in critical articles or reviews.
Notice of Liability
The author and publisher have made every effort to ensure the accuracy of the information herein.
However, the information contained in this book is sold without warranty, either express or implied.
Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any
damages to be caused either directly or indirectly by the instructions contained in this book, or by the
software or hardware products described herein.
Trademark Notice
Rather than indicating every occurrence of a trademarked name as such, this book uses the names only
in an editorial fashion and to the benefit of the trademark owner with no intention of infringement of
the trademark.
Published by SitePoint Pty. Ltd.
48 Cambridge Street Collingwood
VIC Australia 3066.
Web: www.sitepoint.com
Email: business@sitepoint.com
ISBN 978-0-9805768-1-8
Printed and bound in the United States of America
v
About the Author
As Technical Director for SitePoint, Kevin Yank keeps abreast of all that is new and exciting
in web technology. Best known for the book you are reading right now, he also co-authored
Simply JavaScript
(http://www.sitepoint.com/books/javascript1/) with Cameron Adams and
Everything You Know About CSS Is Wrong!
(http://www.sitepoint.com/books/csswrong1/ )
with Rachel Andrew. In addition, Kevin hosts the
SitePoint Podcast
(http://www.sitepoint.com/podcast/) and writes the
SitePoint Tech Times,
a free email
newsletter that goes out to over 240,000 subscribers worldwide.
Kevin lives in Melbourne, Australia and enjoys speaking at conferences, as well as visiting
friends and family in Canada. He’s also passionate about performing improvised comedy
theater with Impro Melbourne (http://www.impromelbourne.com.au/) and flying light aircraft.
Kevin’s personal blog is
Yes, I’m Canadian
(http://yesimcanadian.com/).
About the Technical Editor
Andrew Tetlaw has been tinkering with web sites as a web developer since 1997. At SitePoint
he is dedicated to making the world a better place through the technical editing of SitePoint
books, kits, articles, and newsletters. He is also a busy father of five, enjoys coffee, and often
neglects his blog at http://tetlaw.id.au/.
About SitePoint
SitePoint specializes in publishing fun, practical, and easy-to-understand content for Web
professionals. Visit http://www.sitepoint.com/ to access our blogs, books, newsletters, articles,
and community forums.
Zgłoś jeśli naruszono regulamin