100% found this document useful (4 votes)
43 views

(Ebook) Learning PHP, MySQL, and JavaScript by Robin Nixon ISBN 9780596157135, 0596157134instant download

The document provides information on various ebooks related to learning PHP, MySQL, and JavaScript by Robin Nixon, including multiple editions and additional resources. It includes links for downloading these ebooks and mentions the publisher, O'Reilly Media, along with copyright details. The table of contents outlines the structure of the book, covering topics from dynamic web content to accessing MySQL using PHP.

Uploaded by

liapizrika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
43 views

(Ebook) Learning PHP, MySQL, and JavaScript by Robin Nixon ISBN 9780596157135, 0596157134instant download

The document provides information on various ebooks related to learning PHP, MySQL, and JavaScript by Robin Nixon, including multiple editions and additional resources. It includes links for downloading these ebooks and mentions the publisher, O'Reilly Media, along with copyright details. The table of contents outlines the structure of the book, covering topics from dynamic web content to accessing MySQL using PHP.

Uploaded by

liapizrika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

(Ebook) Learning PHP, MySQL, and JavaScript by

Robin Nixon ISBN 9780596157135, 0596157134


download

https://ebooknice.com/product/learning-php-mysql-and-
javascript-1216936

Explore and download more ebooks at ebooknice.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooknice.com
to discover even more!

(Ebook) Learning PHP, MySQL & JavaScript by Robin Nixon ISBN


9781491918661, 1491918667

https://ebooknice.com/product/learning-php-mysql-javascript-4761774

(Ebook) Learning PHP MySQL JavaScript and CSS by Robin Nixon


ISBN 9781449319267, 1449319262

https://ebooknice.com/product/learning-php-mysql-javascript-and-css-2618790

(Ebook) Learning PHP, MySQL & JavaScript (Early Release) by


Robin Nixon ISBN 9781492093817, 1492093815

https://ebooknice.com/product/learning-php-mysql-javascript-early-
release-24129590

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles,


James ISBN 9781459699816, 9781743365571, 9781925268492,
1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374
(Ebook) Learning PHP, MySQL & JavaScript - With jQuery, CSS &
HTML5 by Robin Nixon ISBN 9781491978917, 1491978910

https://ebooknice.com/product/learning-php-mysql-javascript-with-jquery-
css-html5-7294746

(Ebook) Learning PHP, MySQL & JavaScript, 6th Edition by Robin


Nixon ISBN 9781492093800, 9781492093824, 1492093807, 1492093823

https://ebooknice.com/product/learning-php-mysql-javascript-6th-
edition-23267530

(Ebook) Learning PHP, MySQL & JavaScript, 7th Edition by Robin


Nixon ISBN 9781098152352, 9781098152291, 1098152352, 1098152298

https://ebooknice.com/product/learning-php-mysql-javascript-7th-
edition-54117148

(Ebook) Learning PHP, MySQL & JavaScript: With jQuery, CSS &
HTML5 (Early Release 5th) by Robin Nixon ISBN 9781491978917,
1491978910

https://ebooknice.com/product/learning-php-mysql-javascript-with-jquery-
css-html5-early-release-5th-6855160

(Ebook) Learning PHP, MySQL, JavaScript, CSS & HTML5, Third


Edition: A Step-by-Step Guide to Creating Dynamic Websites by
Robin Nixon ISBN 9781491949467, 1491949465

https://ebooknice.com/product/learning-php-mysql-javascript-css-
html5-third-edition-a-step-by-step-guide-to-creating-dynamic-
websites-4724548
Learning PHP, MySQL, and
JavaScript

Robin Nixon

Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo


Learning PHP, MySQL, and JavaScript
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 Indexer: Ellen Troutman Zaig


Production Editor: Sumita Mukherji Cover Designer: Karen Montgomery
Copyeditor: Nancy Kotary Interior Designer: David Futato
Proofreader: Kiel Van Horn 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

[M]

1246467361
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

1. Introduction to Dynamic Web Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


HTTP and HTML: Berners-Lee’s Basics 2
The Request/Response Procedure 2
The Benefits of PHP, MySQL, and JavaScript 5
Using PHP 5
Using MySQL 6
Using JavaScript 7
The Apache Web Server 8
About Open Source 9
Bringing It All Together 9
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

iii
3. Introduction to PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Incorporating PHP Within HTML 33
Calling the PHP Parser 34
This Book’s Examples 35
The Structure of PHP 36
Using Comments 36
Basic Syntax 37
Understanding Variables 38
Operators 42
Variable Assignment 45
Multiple-Line Commands 47
Variable Typing 49
Constants 50
The Difference Between the echo and print Commands 51
Functions 52
Variable Scope 53
Test Your Knowledge: Questions 58

4. Expressions and Control Flow in PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61


Expressions 61
Literals and Variables 62
Operators 63
Operator Precedence 64
Associativity 66
Relational Operators 67
Conditionals 70
The if Statement 71
The else Statement 72
The elseif Statement 73
The switch Statement 74
The ? Operator 77
Looping 78
while Loops 78
do...while Loops 80
for Loops 81
Breaking Out of a Loop 83
The continue Statement 84
Implicit and Explicit Casting 84
PHP Dynamic Linking 85
Dynamic Linking in Action 86
Test Your Knowledge: Questions 87

iv | Table of Contents
5. PHP Functions and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
PHP Functions 90
Defining a Function 91
Returning a Value 92
Returning an Array 93
Passing by Reference 94
Returning Global Variables 95
Recap of Variable Scope 96
Including and Requiring Files 96
The include Statement 96
Using include_once 97
Using require and require_once 97
PHP Version Compatibility 98
PHP Objects 98
Terminology 99
Declaring a Class 100
Creating an Object 101
Accessing Objects 101
Constructors 104
Writing Methods 105
Declaring Properties 106
Declaring Constants 107
Property and Method Scope in PHP 5 107
Inheritance 109
Test Your Knowledge: Questions 113

6. PHP Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115


Basic Access 115
Numerically Indexed Arrays 115
Associative Arrays 117
Assignment Using the array Keyword 118
The foreach...as Loop 119
Multidimensional Arrays 121
Using Array Functions 123
is_array() 123
count() 124
sort() 124
shuffle() 124
explode() 125
extract() 125
compact() 126
reset() 127
end() 128

Table of Contents | v
Test Your Knowledge: Questions 128

7. Practical PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129


Using printf 129
Precision Setting 131
String Padding 132
Using sprintf 133
Date and Time Functions 133
Date Constants 136
Using checkdate 136
File Handling 137
Checking Whether a File Exists 137
Creating a File 137
Reading from Files 139
Copying Files 139
Moving a File 140
Deleting a File 140
Updating Files 141
Locking Files for Multiple Accesses 142
Reading an Entire File 143
Uploading Files 144
System Calls 149
XHTML 151
The Benefits of XHTML 151
XHTML Versions 151
What’s Different? 152
HTML 4.01 Document Types 153
XHTML 1.0 Document Types 153
XHTML Validation 154
Test Your Knowledge: Questions 155

8. Introduction to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157


MySQL Basics 157
Summary of Database Terms 158
Accessing MySQL via the Command Line 158
Starting the Command-Line Interface 159
Using the Command-Line Interface 163
MySQL Commands 164
Data Types 168
Indexes 177
Creating an Index 178
Querying a MySQL Database 183
Joining Tables Together 192

vi | Table of Contents
Using Logical Operators 194
MySQL Functions 194
Accessing MySQL via phpMyAdmin 195
Windows Users 195
Mac OS X Users 195
Linux Users 195
Using phpMyAdmin 197
Test Your Knowledge: Questions 198

9. Mastering MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201


Database Design 201
Primary Keys: The Keys to Relational Databases 202
Normalization 203
First Normal Form 204
Second Normal Form 206
Third Normal Form 208
When Not to Use Normalization 210
Relationships 211
One-to-One 211
One-to-Many 212
Many-to-Many 212
Databases and Anonymity 214
Transactions 214
Transaction Storage Engines 215
Using BEGIN 216
Using COMMIT 216
Using ROLLBACK 216
Using EXPLAIN 217
Backing Up and Restoring 218
Using mysqldump 219
Creating a Backup File 220
Restoring from a Backup File 222
Dumping Data in CSV Format 222
Planning Your Backups 223
Test Your Knowledge: Questions 223

10. Accessing MySQL Using PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225


Querying a MySQL Database with PHP 225
The Process 225
Creating a Login File 226
Connecting to MySQL 227
A Practical Example 232
The $_POST Array 234

Table of Contents | vii


Deleting a Record 235
Displaying the Form 236
Querying the Database 236
Running the Program 237
Practical MySQL 238
Creating a Table 238
Describing a Table 239
Dropping a Table 240
Adding Data 240
Retrieving Data 241
Updating Data 242
Deleting Data 242
Using AUTO_INCREMENT 243
Performing Additional Queries 244
Preventing SQL Injection 245
Preventing HTML Injection 248
Test Your Knowledge: Questions 250

11. Form Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251


Building Forms 251
Retrieving Submitted Data 253
register_globals: An Old Solution Hangs On 254
Default Values 254
Input Types 256
Text Boxes 256
Text Areas 256
Checkboxes 257
Radio Buttons 259
Hidden Fields 260
Select 260
Labels 262
Sanitizing Input 262
An Example Program 264
Test Your Knowledge: Questions 266

12. Templating with Smarty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269


Why Smarty? 270
Installation 270
Creating Scripts 271
Creating Templates 272
A Practical Example 272
Test Your Knowledge: Questions 277

viii | Table of Contents


13. Cookies, Sessions, and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Using Cookies in PHP 279
Setting a Cookie 281
Accessing a Cookie 281
Destroying a Cookie 282
HTTP Authentication 282
Storing Usernames and Passwords 285
Salting 285
Using Sessions 289
Starting a Session 289
Ending a Session 292
Session Security 293
Test Your Knowledge: Questions 296

14. Exploring JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299


JavaScript and HTML Text 299
Using Scripts Within a Document Head 301
Older and Nonstandard Browsers 301
Including JavaScript Files 302
Debugging JavaScript Errors 303
Using Comments 305
Semicolons 305
Variables 306
String Variables 306
Numeric Variables 307
Arrays 307
Operators 308
Arithmetic Operators 308
Assignment Operators 308
Comparison Operators 309
Logical Operators 309
Variable Incrementing and Decrementing 310
String Concatenation 310
Escaping Characters 310
Variable Typing 311
Functions 312
Global Variables 312
Local Variables 312
The Document Object Model 314
Browser Incompatibilities 316
Using the DOM 317
Test Your Knowledge: Questions 318

Table of Contents | ix
15. Expressions and Control Flow in JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Expressions 319
Literals and Variables 320
Operators 321
Operator Precedence 321
Associativity 322
Relational Operators 323
The with Statement 325
Using onError 326
Using try...catch 327
Conditionals 328
The if Statement 328
The switch Statement 329
The ? Operator 331
Looping 331
while Loops 331
do...while Loops 332
for Loops 332
Breaking Out of a Loop 333
The continue Statement 334
Explicit Casting 334
Test Your Knowledge: Questions 335

16. JavaScript Functions, Objects, and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337


JavaScript Functions 337
Defining a Function 337
Returning a Value 339
Returning an Array 341
JavaScript Objects 341
Declaring a Class 341
Creating an Object 343
Accessing Objects 343
The prototype Keyword 344
JavaScript Arrays 346
Numeric Arrays 346
Associative Arrays 347
Multidimensional Arrays 348
Using Array Methods 349
Test Your Knowledge: Questions 353

17. JavaScript and PHP Validation and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . 355


Validating User Input with JavaScript 355
The validate.html Document (Part One) 356

x | Table of Contents
The validate.html Document (Part Two) 358
Regular Expressions 361
Matching Through Metacharacters 361
Fuzzy Character Matching 362
Grouping Through Parentheses 363
Character Classes 363
Indicating a Range 364
Negation 364
Some More Complicated Examples 364
Summary of Metacharacters 367
General Modifiers 369
Using Regular Expressions in JavaScript 369
Using Regular Expressions in PHP 369
Redisplaying a Form After PHP Validation 370
Test Your Knowledge: Questions 375

18. Using Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377


What Is Ajax? 378
Using XMLHttpRequest 378
Your First Ajax Program 380
Using GET Instead of POST 385
Sending XML Requests 387
Test Your Knowledge: Questions 391

19. Using YUI for Ajax and More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393


Choosing a Framework 393
Using YUI 394
Compressed Versions 396
Using YUI for Ajax 396
Other Uses for YUI 400
A Simple YUI Calendar 401
Test Your Knowledge: Questions 403

20. Bringing It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405


Designing a Social Networking Site 405
About Third-Party Add-Ons 406
On the Website 406
rnfunctions.php 406
The Functions 407
rnheader.php 409
rnsetup.php 410
index.php 411
rnsignup.php 412

Table of Contents | xi
Checking for Username Availability 412
rnsignup.php (YUI version) 415
rncheckuser.php 417
rnlogin.php 417
rnprofile.php 419
Adding the “About Me” Text 420
Adding a Profile Image 420
Processing the Image 420
Displaying the Current Profile 421
rnmembers.php 424
Viewing a User’s Profile 424
Adding and Dropping Friends 424
Listing All Members 424
rnfriends.php 427
rnmessages.php 430
rnlogout.php 432

A. Solutions to the Chapter Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435

B. Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

C. MySQL’s FULLTEXT Stopwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

D. MySQL Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461

E. Using PEAR and PHPUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485

xii | Table of Contents


Preface

The combination of PHP and MySQL is the most convenient approach to dynamic,
database-driven web design, holding its own in the face of challenges from integrated
frameworks—such as Ruby on Rails—that are harder to learn. Due to its open source
roots (unlike the competing Microsoft .NET framework), it is free to implement and is
therefore an extremely popular option for web development.
Any would-be developer on a Unix/Linux or even a Windows/Apache platform will
need to master these technologies. At the same time, the JavaScript is important, as it
provides the hidden communication with the web server to create seamless interfaces.

Audience
This book is for people who wish to learn how to create effective and dynamic websites.
This may include webmasters or graphic designers who are already creating static web-
sites but wish to take their skills to the next level as well as high school and college
students, recent graduates, and self-taught individuals.
In fact, anyone ready to learn the fundamentals behind the Web 2.0 technology known
as Ajax will obtain a thorough grounding in all three of the core technologies: PHP,
MySQL, and JavaScript.

Assumptions This Book Makes


This book assumes that you have a basic understanding of HTML and can at least put
together a simple, static website, but does not assume that you have any prior knowl-
edge of PHP, MySQL, or JavaScript—although if you do, your progress through the
book will be even quicker.

xiii
Organization of This Book
The chapters in this book are written in a specific order, first introducing all three of
the core technologies it covers and then walking you through their installation on a
web development server, so that you will be ready to work through the examples.
In the following section, you will gain a grounding in the PHP programming language,
covering the basics of syntax, arrays, functions, and object-oriented programming.
Then, with PHP under your belt, you will move on to an introduction to the MySQL
database system, where you will learn everything from how MySQL databases are
structured up to generating complex queries.
After that, you will learn how you can combine PHP and MySQL to start creating your
own dynamic web pages by integrating forms and other HTML features. You will then
spend some time looking at ways to speed up your web development using Smarty
templates.
In the next three chapters, you will get down to the nitty-gritty practical aspects of PHP
and MySQL development by learning a variety of useful functions and how to manage
cookies and sessions, as well as how to maintain a high level of security.
In the following four chapters, you will gain a thorough grounding in JavaScript, from
simple functions and event handling to accessing the Document Object Model and in-
browser validation and error handling.
With an understanding of all three of these core technologies, you will then learn how
to make behind-the-scenes Ajax calls and turn your websites into highly dynamic
environments.
Finally, you’ll put together everything you’ve learned in a complete set of PHP programs
that together constitute a fully working social networking website.
Along the way, you’ll also find plenty of pointers and advice on good programming
practices and tips that could help you find and solve hard-to-detect programming er-
rors. There are also plenty of links to websites containing further details on the topics
covered.

Supporting Books
Once you have learned to develop using PHP, MySQL, and JavaScript you will be ready
to take your skills to the next level using the following reference books:
• Dynamic HTML: The Definitive Reference by Danny Goodman (O’Reilly)
• PHP in a Nutshell by Paul Hudson (O’Reilly)
• MySQL in a Nutshell by Russell Dyer (O’Reilly)
• JavaScript: The Definitive Guide by David Flanagan (O’Reilly)

xiv | Preface
Conventions Used in This Book
The following typographical conventions are used in this book:
Plain text
Indicates menu titles, options, and buttons.
Italic
Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames,
directories, and Unix utilities.
Constant width
Indicates command-line options, variables and other code elements, HTML tags,
macros, the contents of files, and the output from commands.
Constant width bold
Shows commands or other text that should be typed literally by the user; also
occasionally used for emphasis.
Constant width italic
Shows text that should be replaced with user-supplied values.

This icon signifies a tip, suggestion, or general note.

This icon indicates a warning or caution.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Learning PHP, MySQL, and JavaScript, by
Robin Nixon. Copyright 2009 Robin Nixon, 978-0-596-15713-5.”
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at permissions@oreilly.com.

Preface | xv
We’d Like to Hear from You
Every example in this book has been tested on various platforms, but occasionally you
may encounter problems; for example, if you have a nonstandard installation or a dif-
ferent version of PHP, and so on. The information in this book has also been verified
at each step of the production process. However, mistakes and oversights can occur
and we will gratefully receive details of any you find, as well as any suggestions you
would like to make for future editions. You can contact the author and editors at:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://www.oreilly.com/catalog/9780596157135
There is also a companion website to this book available online at:
http://lpmj.net
where you can see all the examples with color-highlighted syntax. To comment or ask
technical questions about this book, send email to the following address, mentioning
its ISBN number (9780596157135):
bookquestions@oreilly.com
For more information about our books, conferences, Resource Centers, and the
O’Reilly Network, see our website at:
http://www.oreilly.com

Safari® Books Online


When you see a Safari® Books Online icon on the cover of your favorite
technology book, that means the book is available online through the
O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily
search thousands of top tech books, cut and paste code samples, download chapters,
and find quick answers when you need the most accurate, current information. Try it
for free at http://my.safaribooksonline.com.

xvi | Preface
Acknowledgments
A huge thank you goes to my editor, Andy Oram, and all the folks at O’Reilly who
worked so hard on this book, and without whom it could never have been written.
In particular I must thank my technical reviewers, Derek DeHart, Christoph Dorn,
Tomislav Dugandzic, Becka Morgan, Harry Nixon, Alan Solis, and Demian Turner, for
their help in ensuring the accuracy of this book.
I wish to also thank my wife, Julie, for her constant encouragement, and also Rachel,
Hannah, Laura, Matthew, Harry, and Naomi, wonderful children who all helped with
this project—each in their own way.

Preface | xvii
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of Fairview Boys
and Their Rivals; or, Bob Bouncer's Schooldays
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Fairview Boys and Their Rivals; or, Bob Bouncer's


Schooldays

Author: Frederick Gordon

Release date: April 13, 2016 [eBook #51749]


Most recently updated: October 23, 2024

Language: English

Credits: E-text prepared by Giovanni Fini and the Online


Distributed Proofreading Team (http://www.pgdp.net)
from page images generously made available by
Internet Archive (https://archive.org)

*** START OF THE PROJECT GUTENBERG EBOOK FAIRVIEW BOYS


AND THEIR RIVALS; OR, BOB BOUNCER'S SCHOOLDAYS ***
The Project Gutenberg eBook, Fairview Boys and Their Rivals, by
Frederick Gordon

Note: Images of the original pages are available through Internet


Archive. See
https://archive.org/details/fairviewboysthei00gord
Bob Ran with the Pail to a Man at the Broken-in
Door
Frontispiece
FAIRVIEW BOYS AND
THEIR RIVALS

OR

BOB BOUNCER’S SCHOOLDAYS

BY
FREDERICK GORDON
AUTHOR OF “THE YOUNG CRUSOES OF PINE ISLAND,”
“SAMMY BROWN’S TREASURE HUNT,” ETC.

ILLUSTRATED
CHARLES E. GRAHAM & CO.
NEWARK, N. J. — NEW YORK

BOOKS FOR BOYS


By FREDERICK GORDON
FAIRVIEW BOYS SERIES
Illustrated. Price, per volume,
60 cents, postpaid.

FAIRVIEW BOYS AFLOAT AND


ASHORE
Or, The Young Crusoes of Pine
Island
FAIRVIEW BOYS ON EAGLE
MOUNTAIN
Or, Sammy Brown’s Treasure Hunt
FAIRVIEW BOYS AND THEIR RIVALS
Or, Bob Bouncer’s Schooldays
FAIRVIEW BOYS AT CAMP MYSTERY
Or, The Old Hermit and His Secret
FAIRVIEW BOYS AT LIGHTHOUSE
COVE
Or, Carried Out to Sea
Copyright, 1912, by

GRAHAM & MATLACK


Under The Title
Bob Bouncer’s Schooldays
CONTENTS

CHAPTER PAGE
I. Three Chums 7
II. The First Day at School 18
III. The Lost Letters 30
IV. Something of a Mystery 38
V. The Big Bonfire 50
VI. Bombarded 56
VII. The Spelling Contest 64
VIII. The Mad Bull 71
IX. The Nutting Party 79
X. “The Day of Their Lives” 85
XI. Robbery 93
XII. Bob Bouncer’s Clew 100
XIII. An Exciting Hour 108
XIV. Fire 115
XV. The Capture—Conclusion 124
Fairview Boys and Their Rivals
OR

BOB BOUNCER’S SCHOOLDAYS


CHAPTER I
THREE CHUMS

“Well, fellows,” said Frank Haven, “the long vacation is over at


last.”
“And now for school and study,” added Sammy Brown.
“And fun!” echoed Bob Bouncer.
He was well named, was this Bob Bouncer. On this bright
September morning, Bob looked full of vim and go. He skipped along
the pretty village road like the active lad he was, bounding through
life with a laugh and a cheer, and getting out of it plenty of fun and
frolic.
“Don’t look so glum, Sammy!” he cried. “If any fellows had a
grand old vacation to brag of, it’s us three.”
“Yes, that’s so, and no mistake,” replied Sammy. “I’m not
grumbling. I was just wishing that the boating, and the swimming,
and getting wrecked on Pine Island, and that dandy time in the
mountains, could last forever.”
“Well,” said Bob, “school isn’t going to be a prison, is it?
Especially this school. I found something this morning, and they say
it’s a sign that things will be stirring right along.”
“What is it, Bob?” asked Sammy, eagerly.
“A lucky stone,” replied Bob, with a chuckle, producing the object
in question.
“Maybe it means that you’re going to be put into a higher class,”
spoke Frank, with a smile.
“Or that we’re going to get half-holiday Fridays,” said Bob.
“Or that Jed Burr is going to leave school,” put in Sammy, with a
wry grimace.
“Huh! no fear of Jed leaving,” said Bob. “He’ll stick on till he’s too
old to stick any longer, and pester the life out of every one he
meets.”
“Are you afraid of him, Bob?” asked Sammy, slyly.
“Afraid?” cried Bob. “I guess not! He’s just like a gnat or a
hornet.”
“I’m not going to play with him,” said Sammy.
“You’ll have to, in the football game,” replied Frank.
“Well, I won’t at other times. He got me in trouble last term in a
mean, sneaky way, and I won’t give him a chance again. Tell you
one thing, fellows.”
“And what’s that, Sammy?”
“If Jed Burr tries any of his sly tricks on me this term, he’ll find
me ready for him.”
“How ready, Sammy?” asked Bob, with a sharp look at his
comrade.
“That’s a secret,” chuckled Sammy. “But you wait and see.”
“There’s the half-past bell,” sang out Bob. “Let’s hurry and see
what’s going on before school begins.”
The Fairview schoolhouse was about half a mile from Bob’s
home. He, Frank and Sammy lived near together. They had taken
the bluff road lining Rainbow Lake. Just beyond the curve they were
turning, the schoolhouse would come into view.
Bob broke into a run, swinging his books at the end of a strap
gaily. Just past the stone wall and the line of trees shutting out the
view, he halted dead short.
“What’s he staring at, I wonder?” said Frank.
“Don’t know. Let’s find out,” replied Sammy, and both hurried on.
“The mischief!” shouted Sammy.
He, too, halted. Frank joined them, and the three lads for a
moment stood looking in wonder down the slanting road.
“It’s a runaway automobile,” cried Sammy.
“And a boy in it,” added Frank.
“Whew! there’s a tumble,” shouted Bob, dancing up and down in
a state of great excitement.
Not fifty feet away from them, near a vacant house, an
automobile was coming towards them. A boy in its front seat
seemed to have been trying to turn around. When Bob and his
chums first caught sight of the machine, they saw that this boy was
trying to stop it, but he did not seem to know how to go about the
task.
In some way he had gotten mixed up on the steering gear, and
the auto crossed the road sideways. As it reached the edge of the
road, its front wheels struck a fallen tree. As the auto passed over
the log, there was a big jolt. The boy in the machine was lifted up in
his seat, and either jumped or fell flat into a great puddle of mud.
“Frank,” cried Bob, “see where it’s headed!”
“Say, it’s a goner!” gasped Sammy.
Frank was the only one of the three who knew much about an
automobile, and that was very little. An uncle of his owned a
machine, and he had spent a day or two lately with his relatives at
Fairview. Frank had gone on several runs with his uncle. He had
noticed how his relative had handled the automobile, but in a
general way only. As he ran towards the machine now, he hardly
knew what he should do to stop it.
The runaway automobile was not going very fast. It was the way
it was headed that made Frank realize that something must be done.
The machine was tearing up the earth, and running against rocks,
and bumping past trees, directly at the edge of the bluff road.
“If it keeps on that way,” said Frank to himself, “it will go over the
edge of the bluff.”
If that happened the auto would be wrecked. It would roll over
and over down quite a steep slant until it reached Rainbow Lake.
“Don’t get in! don’t get in!” shouted Sammy, his eyes nearly
bolting out of his head, as he saw no chance to stop the auto.
Frank could hardly have jumped into the machine, it wobbled
about so. But he reached its side, ran along with it, and then jumped
to the step.
Once Frank had been with his uncle when his auto, turning a
sharp curve, nearly ran into a great load of hay blocking the road.
Frank remembered that his uncle had acted as quick as lightning. He
had shot out his hand and grasped the side brake, at the same time
turning off the power at the wheel.
“That was a narrow graze,” his uncle had told him, as the
machine stopped short.
He called it “killing the engine.” All this was in Frank’s mind as he
now gave the brake of the runaway auto a quick wrench and at the
same time shoved back the controls on the steering wheel. As a
sway of the auto threw him off the step, the chug! chug! of the
machine stopped, and so did the auto itself.
The big red car had one wheel wedged between two rocks. Frank
breathed pretty hard as he noticed that had the auto gone ten feet
farther, it would have toppled over the cliff.
“Oh, say, you’ve done a big thing,” panted Sammy, running up to
the spot.
“I’m glad it didn’t go over the bluff,” said Frank.
He might well say this. As he glanced down the slant, Frank
almost became frightened. Three little huts, where some fishermen
and their families lived, were right in the course the auto might take.
Just now some small children were playing near one of the huts.
“Say, if it hit those houses—say, if it smashed over those children
——” began Sammy, in a gasp.
“Where is Bob?” asked Frank.
“He’s helping the fellow who tumbled out of the auto,” explained
Sammy.
Frank turned around, to see Bob back at the spot where the boy
in the auto had taken his tumble into the mud puddle.
Bob had helped the boy out of the water and mire. Just now he
was rubbing the mud from his coat with some dry grass. The victim
of the accident was mopping his face with a handkerchief.
“Here comes the man who owns the automobile, I guess,” said
Sammy.
Frank saw a man rush down the road from the direction of the
vacant house. He was in a great hurry, and excited. He shouted
some words at Bob and his companion, and, passing Frank and
Sammy, gasping for breath, ran to the automobile.
As he looked it over and saw that he could get it back into the
roadway without risk or damage, he walked up to the boys.
“One of you stopped that machine,” he said, glancing from Frank
to Sammy.
“It was Frank, mister,” said Sammy, pointing to his chum.
“I haven’t got much with me,” spoke the man, his voice
trembling.
First he shook Frank’s hand warmly. Then he groped in his pocket
and drew out a bright new silver dollar.
“You take that till I see you again,” he said.
“No, no,” replied Frank. “I don’t want any pay for doing the little I
did.”
“Little!” cried the man, pressing the coin on Frank. “That machine
is worth three thousand dollars, and you saved it.”
“Well, I’m glad if I did,” said Frank.
“If that boy back there was my boy,” spoke the man, with a look
at the lad who had tumbled out of the auto, “I’d either teach him
how to run the machine, or handcuff him when he was aboard.”
“Oh, isn’t he your boy?” inquired Sammy.
“No, I’m his father’s chauffeur.”
They all went up to the mud puddle. Bob was helping his
companion get cleaned up in as friendly a way as if they had been
chums for years.
“Why,” shouted Sammy, in blank surprise, “it’s the fat boy.”
“So it is,” replied Frank, in a wondering tone.
“Hello,” spoke the boy who had tumbled out of the auto. “You
fellows here, too?”
Bob’s face, as were the faces of the others, was set in a broad
smile. They all had good reason to remember “the fat boy.”
“Yes, it’s me,” said the victim of the accident, rubbing some dirt
out of one ear. “Is the machine all right, Buxton?”
“Yes, the machine is all right,” replied the man; “but ten feet
more, and it would have been all wrong. What was you trying to do
with it, anyhow?”
“I thought I would turn it around. I only touched one little
handle, and then the foot-plate, and the pesky auto wouldn’t go
straight at all. Yes, fellows,” smiled the speaker at Frank and Sammy,
“I’m like the bad penny, turned up again.”
“I’m glad to see you in Fairview,” said Frank. “How are you
getting on at the academy?”
“Oh, I’ve quit there,” said Tom Chubb, otherwise “the fat boy.”
“How is that?”
“They said I wasn’t far enough along to keep up with the class.”
“I see.”
“You know I don’t know much,” said the fat boy, frankly. “The
fellows all made fun of me. Then they got mad. I couldn’t hit back
when they fought me, I was so fat. Well, all I could do was to get
them in a corner and fall on them.”
“Ha! ha!” laughed Sammy.
“That’s pretty good,” chuckled Bob.
“Father is thinking of coming to Fairview to live for the summer,”
went on the fat boy. “I think we’ll take that vacant house Buxton
was just looking at.”
“Why, then, you may come to our school?” said Sammy.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like