100% found this document useful (1 vote)
16 views68 pages

Learning PHP MySQL JavaScript With jQuery CSS HTML5 5th Edition Robin Nixon download

The document provides information on various editions of the book 'Learning PHP, MySQL & JavaScript' by Robin Nixon, along with links to download the full versions. It includes a detailed table of contents covering topics such as setting up a development server, PHP basics, MySQL introduction, and practical applications. The book aims to teach web development using PHP, MySQL, JavaScript, CSS, and HTML5.

Uploaded by

askpzohl7871
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 (1 vote)
16 views68 pages

Learning PHP MySQL JavaScript With jQuery CSS HTML5 5th Edition Robin Nixon download

The document provides information on various editions of the book 'Learning PHP, MySQL & JavaScript' by Robin Nixon, along with links to download the full versions. It includes a detailed table of contents covering topics such as setting up a development server, PHP basics, MySQL introduction, and practical applications. The book aims to teach web development using PHP, MySQL, JavaScript, CSS, and HTML5.

Uploaded by

askpzohl7871
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/ 68

Learning PHP MySQL JavaScript With jQuery CSS

HTML5 5th Edition Robin Nixon download

https://textbookfull.com/product/learning-php-mysql-javascript-
with-jquery-css-html5-5th-edition-robin-nixon/

Download full version ebook from https://textbookfull.com


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

Learning PHP, MySQL & JavaScript, 6th Edition Robin


Nixon

https://textbookfull.com/product/learning-php-mysql-
javascript-6th-edition-robin-nixon/

Learning PHP MySQL JavaScript Early Release 6th Edition


Robin Nixon

https://textbookfull.com/product/learning-php-mysql-javascript-
early-release-6th-edition-robin-nixon/

Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5


Second Edition Steve Prettyman

https://textbookfull.com/product/learn-php-8-using-mysql-
javascript-css3-and-html5-second-edition-steve-prettyman/

HTML5 20 Lessons to Successful Web Development 1st


Edition Robin Nixon

https://textbookfull.com/product/html5-20-lessons-to-successful-
web-development-1st-edition-robin-nixon/
Responsive Web Design by Example Embrace responsive
design with HTML5 CSS3 JavaScript jQuery and Bootstrap
4 Hussain

https://textbookfull.com/product/responsive-web-design-by-
example-embrace-responsive-design-with-html5-css3-javascript-
jquery-and-bootstrap-4-hussain/

PHP and MySQL Web Development 5th Edition Developer s


Library Luke Welling

https://textbookfull.com/product/php-and-mysql-web-
development-5th-edition-developer-s-library-luke-welling/

Beginning PHP and MySQL: From Novice to Professional


5th Edition Frank M. Kromann

https://textbookfull.com/product/beginning-php-and-mysql-from-
novice-to-professional-5th-edition-frank-m-kromann/

Programming Windows Store Apps with HTML CSS and


JavaScript Kraig Brockschmidt

https://textbookfull.com/product/programming-windows-store-apps-
with-html-css-and-javascript-kraig-brockschmidt/

PHP and MySQL for Dynamic Web Sites Fifth Edition


Ullman

https://textbookfull.com/product/php-and-mysql-for-dynamic-web-
sites-fifth-edition-ullman/
5t I n c l p s &
h ud M
W

Ed es ob
eb

iti
Ap

on
ile
Learning
PHP, MySQL,
& JavaScript
WITH JQUERY, CSS & HTML5

Robin Nixon
FIFTH EDITION

Learning PHP, MySQL & JavaScript


With jQuery, CSS & HTML5

Robin Nixon

Beijing Boston Farnham Sebastopol Tokyo


Learning PHP, MySQL & JavaScript
by Robin Nixon
Copyright © 2018 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://oreilly.com/safari). For more information, contact our corporate/insti‐
tutional sales department: 800-998-9938 or [email protected].

Editor: Andy Oram Indexer: Judy McConville


Production Editor: Melanie Yarbrough Interior Designer: David Futato
Copyeditor: Rachel Head Cover Designer: Karen Montgomery
Proofreader: Rachel Monaghan Illustrator: Rebecca Demarest

July 2009: First Edition


August 2012: Second Edition
June 2014: Third Edition
December 2018: Fourth Edition
May 2018: Fifth Edition

Revision History for the Fifth Edition


2018-05-08: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781491978917 for release details.

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning PHP, MySQL & JavaScript, the
cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.

978-1-491-97891-7
[M]
For Julie
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

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, JavaScript, CSS, and HTML5 5
MariaDB: The MySQL Clone 6
Using PHP 6
Using MySQL 7
Using JavaScript 8
Using CSS 10
And Then There’s HTML5 10
The Apache Web Server 11
Handling Mobile Devices 12
About Open Source 12
Bringing It All Together 13
Questions 14

2. Setting Up a Development Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17


What Is a WAMP, MAMP, or LAMP? 18
Installing AMPPS on Windows 18
Testing the Installation 22
Accessing the Document Root (Windows) 24
Alternative WAMPs 25
Installing AMPPS on macOS 26
Accessing the Document Root (macOS) 27
Installing a LAMP on Linux 28
Working Remotely 28

v
Logging In 29
Using FTP 29
Using a Program Editor 30
Using an IDE 31
Questions 33

3. Introduction to PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Incorporating PHP Within HTML 35
This Book’s Examples 37
The Structure of PHP 38
Using Comments 38
Basic Syntax 39
Variables 40
Operators 45
Variable Assignment 48
Multiple-Line Commands 50
Variable Typing 52
Constants 53
Predefined Constants 54
The Difference Between the echo and print Commands 55
Functions 55
Variable Scope 56
Questions 62

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


Expressions 63
TRUE or FALSE? 64
Literals and Variables 65
Operators 66
Operator Precedence 67
Associativity 69
Relational Operators 70
Conditionals 74
The if Statement 75
The else Statement 76
The elseif Statement 78
The switch Statement 79
The ? Operator 82
Looping 83
while Loops 84
do...while Loops 86
for Loops 86

vi | Table of Contents
Breaking Out of a Loop 88
The continue Statement 89
Implicit and Explicit Casting 90
PHP Dynamic Linking 91
Dynamic Linking in Action 92
Questions 93

5. PHP Functions and Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95


PHP Functions 96
Defining a Function 97
Returning a Value 98
Returning an Array 99
Passing Arguments by Reference 100
Returning Global Variables 102
Recap of Variable Scope 102
Including and Requiring Files 103
The include Statement 103
Using include_once 103
Using require and require_once 104
PHP Version Compatibility 104
PHP Objects 105
Terminology 106
Declaring a Class 107
Creating an Object 108
Accessing Objects 108
Cloning Objects 110
Constructors 111
Destructors 111
Writing Methods 112
Declaring Properties 113
Declaring Constants 113
Property and Method Scope 114
Static Methods 115
Static Properties 116
Inheritance 117
Questions 120

6. PHP Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123


Basic Access 123
Numerically Indexed Arrays 123
Associative Arrays 125
Assignment Using the array Keyword 126

Table of Contents | vii


The foreach...as Loop 127
Multidimensional Arrays 129
Using Array Functions 132
is_array 132
count 132
sort 133
shuffle 133
explode 133
extract 134
compact 135
reset 136
end 136
Questions 137

7. Practical PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139


Using printf 139
Precision Setting 140
String Padding 142
Using sprintf 143
Date and Time Functions 143
Date Constants 146
Using checkdate 146
File Handling 147
Checking Whether a File Exists 147
Creating a File 147
Reading from Files 149
Copying Files 150
Moving a File 150
Deleting a File 151
Updating Files 151
Locking Files for Multiple Accesses 153
Reading an Entire File 154
Uploading Files 155
System Calls 161
XHTML or HTML5? 162
Questions 163

8. Introduction to MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165


MySQL Basics 165
Summary of Database Terms 166
Accessing MySQL via the Command Line 166
Starting the Command-Line Interface 167

viii | Table of Contents


Using the Command-Line Interface 171
MySQL Commands 172
Data Types 177
Indexes 187
Creating an Index 187
Querying a MySQL Database 193
Joining Tables Together 203
Using Logical Operators 205
MySQL Functions 206
Accessing MySQL via phpMyAdmin 206
Questions 207

9. Mastering MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


Database Design 209
Primary Keys: The Keys to Relational Databases 210
Normalization 211
First Normal Form 212
Second Normal Form 214
Third Normal Form 216
When Not to Use Normalization 218
Relationships 219
One-to-One 219
One-to-Many 220
Many-to-Many 221
Databases and Anonymity 222
Transactions 223
Transaction Storage Engines 223
Using BEGIN 224
Using COMMIT 225
Using ROLLBACK 225
Using EXPLAIN 226
Backing Up and Restoring 227
Using mysqldump 227
Creating a Backup File 229
Restoring from a Backup File 231
Dumping Data in CSV Format 231
Planning Your Backups 232
Questions 232

10. Accessing MySQL Using PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235


Querying a MySQL Database with PHP 235
The Process 235

Table of Contents | ix
Creating a Login File 236
Connecting to a MySQL Database 237
A Practical Example 243
The $_POST Array 246
Deleting a Record 247
Displaying the Form 247
Querying the Database 248
Running the Program 249
Practical MySQL 250
Creating a Table 251
Describing a Table 251
Dropping a Table 252
Adding Data 253
Retrieving Data 254
Updating Data 255
Deleting Data 255
Using AUTO_INCREMENT 256
Performing Additional Queries 257
Preventing Hacking Attempts 258
Steps You Can Take 259
Using Placeholders 260
Preventing HTML Injection 263
Using mysqli Procedurally 264
Questions 266

11. Form Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267


Building Forms 267
Retrieving Submitted Data 269
Default Values 270
Input Types 271
Sanitizing Input 278
An Example Program 280
HTML5 Enhancements 283
The autocomplete Attribute 283
The autofocus Attribute 283
The placeholder Attribute 283
The required Attribute 284
Override Attributes 284
The width and height Attributes 284
The min and max Attributes 284
The step Attribute 284
The form Attribute 285

x | Table of Contents
The list Attribute 285
The color Input Type 285
The number and range Input Types 285
Date and Time Pickers 286
Questions 286

12. Cookies, Sessions, and Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287


Using Cookies in PHP 287
Setting a Cookie 289
Accessing a Cookie 290
Destroying a Cookie 290
HTTP Authentication 290
Storing Usernames and Passwords 294
An Example Program 296
Using Sessions 299
Starting a Session 299
Ending a Session 302
Setting a Timeout 303
Session Security 304
Questions 307

13. Exploring JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309


JavaScript and HTML Text 310
Using Scripts Within a Document Head 311
Older and Nonstandard Browsers 311
Including JavaScript Files 312
Debugging JavaScript Errors 313
Using Comments 314
Semicolons 314
Variables 314
String Variables 315
Numeric Variables 315
Arrays 316
Operators 316
Arithmetic Operators 317
Assignment Operators 317
Comparison Operators 318
Logical Operators 318
Incrementing, Decrementing, and Shorthand Assignment 318
String Concatenation 318
Escape Characters 319
Variable Typing 319

Table of Contents | xi
Functions 321
Global Variables 321
Local Variables 321
The Document Object Model 322
Another Use for the $ Symbol 324
Using the DOM 325
About document.write 326
Using console.log 326
Using alert 326
Writing into Elements 326
Using document.write 327
Questions 327

14. Expressions and Control Flow in JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329


Expressions 329
Literals and Variables 330
Operators 331
Operator Precedence 332
Associativity 332
Relational Operators 333
The with Statement 336
Using onerror 337
Using try...catch 338
Conditionals 339
The if Statement 339
The else Statement 339
The switch Statement 340
The ? Operator 342
Looping 342
while Loops 342
do...while Loops 343
for Loops 344
Breaking Out of a Loop 345
The continue Statement 345
Explicit Casting 346
Questions 347

15. JavaScript Functions, Objects, and Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349


JavaScript Functions 349
Defining a Function 349
Returning a Value 351
Returning an Array 353

xii | Table of Contents


JavaScript Objects 354
Declaring a Class 354
Creating an Object 356
Accessing Objects 356
The prototype Keyword 356
JavaScript Arrays 359
Numeric Arrays 360
Associative Arrays 361
Multidimensional Arrays 362
Using Array Methods 363
Questions 368

16. JavaScript and PHP Validation and Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371


Validating User Input with JavaScript 371
The validate.html Document (Part 1) 372
The validate.html Document (Part 2) 374
Regular Expressions 377
Matching Through Metacharacters 378
Fuzzy Character Matching 378
Grouping Through Parentheses 379
Character Classes 380
Indicating a Range 380
Negation 380
Some More Complicated Examples 381
Summary of Metacharacters 383
General Modifiers 385
Using Regular Expressions in JavaScript 385
Using Regular Expressions in PHP 386
Redisplaying a Form After PHP Validation 387
Questions 393

17. Using Asynchronous Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395


What Is Asynchronous Communication? 396
Using XMLHttpRequest 396
Your First Asynchronous Program 399
Using GET Instead of POST 403
Sending XML Requests 406
Using Frameworks for Asynchronous Communication 411
Questions 411

18. Introduction to CSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413


Importing a Stylesheet 414

Table of Contents | xiii


Importing CSS from Within HTML 414
Embedded Style Settings 415
Using IDs 415
Using Classes 415
Using Semicolons 416
CSS Rules 416
Multiple Assignments 416
Using Comments 417
Style Types 418
Default Styles 418
User Styles 418
External Stylesheets 419
Internal Styles 419
Inline Styles 420
CSS Selectors 420
The Type Selector 420
The Descendant Selector 420
The Child Selector 421
The ID Selector 422
The Class Selector 423
The Attribute Selector 424
The Universal Selector 424
Selecting by Group 425
The CSS Cascade 425
Stylesheet Creators 426
Stylesheet Methods 426
Stylesheet Selectors 427
The Difference Between div and span Elements 429
Measurements 431
Fonts and Typography 433
font-family 433
font-style 434
font-size 434
font-weight 435
Managing Text Styles 435
Decoration 435
Spacing 436
Alignment 436
Transformation 436
Indenting 436
CSS Colors 437
Short Color Strings 438

xiv | Table of Contents


Gradients 438
Positioning Elements 440
Absolute Positioning 440
Relative Positioning 440
Fixed Positioning 441
Pseudoclasses 443
Shorthand Rules 445
The Box Model and Layout 446
Setting Margins 446
Applying Borders 448
Adjusting Padding 449
Object Contents 451
Questions 451

19. Advanced CSS with CSS3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453


Attribute Selectors 454
Matching Parts of Strings 454
The box-sizing Property 455
CSS3 Backgrounds 456
The background-clip Property 456
The background-origin Property 458
The background-size Property 458
Using the auto Value 459
Multiple Backgrounds 459
CSS3 Borders 461
The border-color Property 461
The border-radius Property 461
Box Shadows 465
Element Overflow 466
Multicolumn Layout 466
Colors and Opacity 468
HSL Colors 468
HSLA Colors 469
RGB Colors 469
RGBA Colors 469
The opacity Property 470
Text Effects 470
The text-shadow Property 470
The text-overflow Property 470
The word-wrap Property 471
Web Fonts 472
Google Web Fonts 473

Table of Contents | xv
Transformations 474
3D Transformations 475
Transitions 476
Properties to Transition 476
Transition Duration 477
Transition Delay 477
Transition Timing 477
Shorthand Syntax 478
Questions 480

20. Accessing CSS from JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481


Revisiting the getElementById Function 481
The O function 481
The S Function 482
The C Function 483
Including the Functions 484
Accessing CSS Properties from JavaScript 484
Some Common Properties 485
Other Properties 486
Inline JavaScript 488
The this Keyword 488
Attaching Events to Objects in a Script 489
Attaching to Other Events 490
Adding New Elements 491
Removing Elements 492
Alternatives to Adding and Removing Elements 493
Using Interrupts 494
Using setTimeout 494
Canceling a Timeout 495
Using setInterval 495
Using Interrupts for Animation 497
Questions 499

21. Introduction to jQuery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501


Why jQuery? 501
Including jQuery 502
Choosing the Right Version 502
Downloading 504
Using a Content Delivery Network 504
Customizing jQuery 505
jQuery Syntax 505
A Simple Example 506

xvi | Table of Contents


Avoiding Library Conflicts 507
Selectors 507
The css Method 508
The Element Selector 508
The ID Selector 509
The Class Selector 509
Combining Selectors 509
Handling Events 510
Waiting Until the Document Is Ready 511
Event Functions and Properties 512
The blur and focus Events 513
The this Keyword 514
The click and dblclick Events 514
The keypress Event 515
Considerate Programming 517
The mousemove Event 517
Other Mouse Events 520
Alternative Mouse Methods 521
The submit Event 522
Special Effects 523
Hiding and Showing 524
The toggle Method 525
Fading In and Out 526
Sliding Elements Up and Down 527
Animations 528
Stopping Animations 531
Manipulating the DOM 532
The Difference Between the text and html Methods 533
The val and attr Methods 533
Adding and Removing Elements 535
Dynamically Applying Classes 537
Modifying Dimensions 537
The width and height Methods 538
The innerWidth and innerHeight Methods 540
The outerWidth and OuterHeight Methods 540
DOM Traversal 541
Parent Elements 541
Child Elements 545
Sibling Elements 545
Selecting the Next and Previous Elements 547
Traversing jQuery Selections 549
The is Method 550

Table of Contents | xvii


Using jQuery Without Selectors 552
The $.each Method 552
The $.map Method 553
Using Asynchronous Communication 554
Using the POST Method 554
Using the GET Method 555
Plug-ins 555
jQuery User Interface 556
Other Plug-ins 556
Questions 556

22. Introduction to jQuery Mobile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559


Including jQuery Mobile 560
Getting Started 561
Linking Pages 563
Linking Synchronously 563
Linking Within a Multipage Document 564
Page Transitions 565
Styling Buttons 568
List Handling 571
Filterable Lists 572
List Dividers 574
What Next? 577
Questions 577

23. Introduction to HTML5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579


The Canvas 579
Geolocation 581
Audio and Video 583
Forms 584
Local Storage 585
Web Workers 585
Microdata 585
Questions 586

24. The HTML5 Canvas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587


Creating and Accessing a Canvas 587
The toDataURL Function 589
Specifying an Image Type 591
The fillRect Method 591
The clearRect Method 591
The strokeRect Method 592

xviii | Table of Contents


Combining These Commands 592
The createLinearGradient Method 593
The addColorStop Method in Detail 595
The createRadialGradient Method 596
Using Patterns for Fills 598
Writing Text to the Canvas 600
The strokeText Method 600
The textBaseLine Property 601
The font Property 601
The textAlign Property 601
The fillText Method 602
The measureText Method 603
Drawing Lines 603
The lineWidth Property 604
The lineCap and lineJoin Properties 604
The miterLimit Property 606
Using Paths 606
The moveTo and lineTo Methods 607
The stroke Method 607
The rect Method 608
Filling Areas 608
The clip Method 610
The isPointInPath Method 613
Working with Curves 614
The arc Method 614
The arcTo Method 617
The quadraticCurveTo Method 618
The bezierCurveTo Method 619
Manipulating Images 620
The drawImage Method 620
Resizing an Image 621
Selecting an Image Area 621
Copying from a Canvas 623
Adding Shadows 623
Editing at the Pixel Level 625
The getImageData Method 625
The putImageData Method 628
The createImageData Method 628
Advanced Graphical Effects 629
The globalCompositeOperation Property 629
The globalAlpha Property 632
Transformations 632

Table of Contents | xix


The scale Method 633
The save and restore Methods 634
The rotate Method 634
The translate Method 635
The transform Method 636
The setTransform Method 638
Questions 639

25. HTML5 Audio and Video. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641


About Codecs 642
The <audio> Element 643
Supporting Non-HTML5 Browsers 646
The <video> Element 647
The Video Codecs 648
Supporting Older Browsers 651
Questions 653

26. Other HTML5 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655


Geolocation and the GPS Service 655
Other Location Methods 656
Geolocation and HTML5 657
Local Storage 660
Using Local Storage 661
The localStorage Object 661
Web Workers 663
Drag and Drop 666
Cross-Document Messaging 668
Other HTML5 Tags 672
Questions 672

27. Bringing It All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675


Designing a Social Networking App 676
On the Website 676
functions.php 676
The Functions 677
header.php 679
setup.php 682
index.php 683
signup.php 684
Checking for Username Availability 685
Logging In 685
checkuser.php 688

xx | Table of Contents
login.php 689
profile.php 691
Adding the “About Me” Text 692
Adding a Profile Image 692
Processing the Image 692
Displaying the Current Profile 693
members.php 696
Viewing a User’s Profile 696
Adding and Dropping Friends 697
Listing All Members 697
friends.php 700
messages.php 703
logout.php 706
styles.css 708
javascript.js 710

A. Solutions to the Chapter Questions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713

B. Online Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735

C. MySQL’s FULLTEXT Stopwords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739

D. MySQL Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743

E. jQuery Selectors, Objects, and Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777

Table of Contents | xxi


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. And, combined with the partner technologies of
JavaScript, jQuery, CSS, and HTML5, you will be able to create websites of the caliber
of industry standards like Facebook, Twitter, and Gmail.

Audience
This book is for people who wish to learn how to create effective and dynamic web‐
sites. This may include webmasters or graphic designers who are already creating
static websites 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 responsive web design will
obtain a thorough grounding in the core technologies of PHP, MySQL, JavaScript,
CSS, and HTML5, and you’ll learn the basics of the jQuery and jQuery Mobile libra‐
ries, too.

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, JavaScript, CSS, or HTML5—although if you do, your progress
through the book will be even quicker.

xxiii
Organization of This Book
The chapters in this book are written in a specific order, first introducing all 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 first 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 to how to generate 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 get down to the nitty-gritty practical aspects of PHP and MySQL develop‐
ment by learning a variety of useful functions and how to manage cookies and ses‐
sions, as well as how to maintain a high level of security.
In the next few chapters, you will gain a thorough grounding in JavaScript, from sim‐
ple functions and event handling to accessing the Document Object Model, in-
browser validation, and error handling. You’ll also get a comprehensive primer on
using the popular jQuery library for JavaScript.
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.
Next, you’ll spend two chapters learning all about using CSS to style and lay out your
web pages, before discovering how the jQuery libraries can make your development
job a great deal easier. You’ll then move on to the final section on the interactive fea‐
tures built into HTML5, including geolocation, audio, video, and the canvas. After
this, you’ll put together everything you’ve learned in a complete set of programs that
together constitute a fully functional social networking website.
Along the way, you’ll find plenty of advice on good programming practices and tips
that can help you find and solve hard-to-detect programming errors. 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, JavaScript, CSS, and HTML5,
you will be ready to take your skills to the next level using the following O’Reilly ref‐
erence books:

• Dynamic HTML: The Definitive Reference by Danny Goodman

xxiv | Preface
• PHP in a Nutshell by Paul Hudson
• MySQL in a Nutshell by Russell Dyer
• JavaScript: The Definitive Guide by David Flanagan
• CSS: The Definitive Guide by Eric A. Meyer and Estelle Weyl
• HTML5: The Missing Manual by Matthew MacDonald

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, path‐
names, directories, and Unix utilities. Also used for database, table, and column
names.
Constant width
Indicates commands and command-line options, variables and other code ele‐
ments, HTML tags, and the contents of files.
Constant width bold
Shows program output and is used to highlight sections of code that are dis‐
cussed in the text.
Constant width italic
Shows text that should be replaced with user-supplied values.

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

This element indicates a warning or caution.

Preface | xxv
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at
http://lpmj.net.
This book is here to help you get your job done. In general, if example code is offered
with this book, you may use it 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 signifi‐
cant 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 & JavaScript
by Robin Nixon (O’Reilly). Copyright 2018 Robin Nixon, 978-1-491-97891-7.”
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at [email protected].

O’Reilly Safari
Safari (formerly Safari Books Online) is a membership-based
training and reference platform for enterprise, government,
educators, and individuals.

Members have access to thousands of books, training videos, Learning Paths, interac‐
tive tutorials, and curated playlists from over 250 publishers, including O’Reilly
Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Profes‐
sional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press,
John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe
Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and
Course Technology, among others.
For more information, please visit http://oreilly.com/safari.

How to Contact Us
Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.


1005 Gravenstein Highway North

xxvi | Preface
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://bit.ly/lpmjch_5e.
To comment or ask technical questions about this book, send email to bookques‐
[email protected].
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments
I would like to once again thank my editor, Andy Oram, and everyone who worked
so hard on this book, including Jon Reid, Michal Špaček, and John Craig for their
comprehensive technical reviews, Melanie Yarbrough for overseeing production,
Rachel Head for copy editing, Rachel Monaghan for proofreading, Rebecca Demarest
for illustrations, Judy McConville for creating the index, Karen Montgomery for the
original sugar glider front cover design, Randy Comer for the latest book cover, and
everyone else too numerous to name who submitted errata and offered suggestions
for this new edition.

Preface | xxvii
Discovering Diverse Content Through
Random Scribd Documents
The Project Gutenberg eBook of The Night of
the Trolls
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: The Night of the Trolls

Author: Keith Laumer

Illustrator: Virgil Finlay


Norman Nodel

Release date: September 23, 2016 [eBook #53132]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by Greg Weeks, Mary Meehan and the Online


Distributed Proofreading Team at http://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK THE NIGHT OF


THE TROLLS ***
THE NIGHT OF THE TROLLS

BY KEITH LAUMER

ILLUSTRATED BY NODEL

[Transcriber's Note: This etext was produced from


Worlds of Tomorrow October 1963
Extensive research did not uncover any evidence that
the U.S. copyright on this publication was renewed.]
The machine's job was to defend its place
against
enemies—but it had forgotten it had friends!

I
It was different this time. There was a dry pain in my lungs, and a
deep ache in my bones, and a fire in my stomach that made me want
to curl into a ball and mew like a kitten. My mouth tasted as though
mice had nested in it, and when I took a deep breath wooden knives
twisted in my chest.
I made a mental note to tell Mackenzie a few things about his pet
controlled-environment tank—just as soon as I got out of it. I
squinted at the over-face panel: air pressure, temperature, humidity,
O-level, blood sugar, pulse and respiration—all okay. That was
something. I flipped the intercom key and said, "Okay, Mackenzie,
let's have the story. You've got problems...."
I had to stop to cough. The exertion made my temples pound.
"How long have you birds run this damned exercise?" I called. "I feel
lousy. What's going on around here?"
No answer.
This was supposed to be the terminal test series. They couldn't all be
out having coffee. The equipment had more bugs than a two-dollar
hotel room. I slapped the emergency release lever. Mackenzie
wouldn't like it, but to hell with it! From the way I felt, I'd been in the
tank for a good long stretch this time—maybe a week or two. And I'd
told Ginny it would be a three-dayer at the most. Mackenzie was a
great technician, but he had no more human emotions than a used-
car salesman. This time I'd tell him.
Relays were clicking, equipment was reacting, the tank cover sliding
back. I sat up and swung my legs aside, shivering suddenly.
It was cold in the test chamber. I looked around at the dull gray
walls, the data recording cabinets, the wooden desk where Mac sat
by the hour re-running test profiles—
That was funny. The tape reels were empty and the red equipment
light was off. I stood, feeling dizzy. Where was Mac? Where were
Bonner and Day, and Mallon?
"Hey!" I called. I didn't even get a good echo.
Someone must have pushed the button to start my recovery cycle;
where were they hiding now? I took a step, tripped over the cables
trailing behind me. I unstrapped and pulled the harness off. The
effort left me breathing hard. I opened one of the wall lockers;
Banner's pressure suit hung limply from the rack beside a rag-
festooned coat hanger. I looked in three more lockers. My clothes
were missing—even my bathrobe. I also missed the usual bowl of hot
soup, the happy faces of the techs, even Mac's sour puss. It was cold
and silent and empty here—more like a morgue than a top priority
research center.
I didn't like it. What the hell was going on?
There was a weather suit in the last locker. I put it on, set the
temperature control, palmed the door open and stepped out into the
corridor. There were no lights, except for the dim glow of the
emergency route indicators. There was a faint, foul odor in the air.
I heard a dry scuttling, saw a flick of movement. A rat the size of a
red squirrel sat up on his haunches and looked at me as if I were
something to eat. I made a kicking motion and he ran off, but not
very far.
My heart was starting to thump a little harder now. The way it does
when you begin to realize that something's wrong—bad wrong.
Upstairs in the Admin Section, I called again. The echo was a little
better here. I went along the corridor strewn with papers, past the
open doors of silent rooms. In the Director's office, a blackened
wastebasket stood in the center of the rug. The air-conditioner intake
above the desk was felted over with matted dust nearly an inch thick.
There was no use shouting again.
The place was as empty as a robbed grave—except for the rats.
At the end of the corridor, the inner security door stood open. I went
through it and stumbled over something. In the faint light, it took me
a moment to realize what it was.
He had been an M. P., in steel helmet and boots. There was nothing
left but crumbled bone and a few scraps of leather and metal. A .38
revolver lay nearby. I picked it up, checked the cylinder and tucked it
in the thigh pocket of the weather suit. For some reason, it made me
feel a little better.
I went on along B corridor and found the lift door sealed. The
emergency stairs were nearby. I went to them and started the two
hundred foot climb to the surface.
The heavy steel doors at the tunnel had been blown clear.
I stepped past the charred opening, looked out at a low gray sky
burning red in the west. Fifty yards away, the 5000-gallon water tank
lay in a tangle of rusty steel. What had it been? Sabotage, war,
revolution—an accident? And where was everybody?
I rested for a while, then went across the innocent-looking fields to
the west, dotted with the dummy buildings that were supposed to
make the site look from the air like another stretch of farm land
complete with barns, sheds and fences. Beyond the site, the town
seemed intact: there were lights twinkling here and there, a few
smudges of smoke rising.
Whatever had happened at the site, at least Ginny would be all right
—Ginny and Tim. Ginny would be worried sick, after—how long? A
month?
Maybe more. There hadn't been much left of that soldier....

I twisted to get a view to the south, and felt a hollow sensation in my


chest. Four silo doors stood open; the Colossus missiles had hit back
—at something. I pulled myself up a foot or two higher for a look at
the Primary Site. In the twilight, the ground rolled smooth and
unbroken across the spot where Prometheus lay ready in her
underground berth. Down below, she'd be safe and sound maybe.
She had been built to stand up to the stresses of a direct extra-solar
orbital launch; with any luck, a few near-misses wouldn't have
damaged her.
My arms were aching from the strain of holding on. I climbed down
and sat on the ground to get my breath, watching the cold wind
worry the dry stalks of dead brush around the fallen tank.
At home, Ginny would be alone, scared, maybe even in serious
difficulty. There was no telling how far municipal services had broken
down. But before I headed that way, I had to make a quick check on
the ship. Prometheus was a dream that I—and a lot of others—had
lived with for three years. I had to be sure.
I headed toward the pillbox that housed the tunnel head on the off-
chance that the car might be there.
It was almost dark and the going was tough; the concrete slabs
under the sod were tilted and dislocated. Something had sent a ripple
across the ground like a stone tossed into a pond.
I heard a sound and stopped dead. There was a clank and rumble
from beyond the discolored walls of the blockhouse a hundred yards
away. Rusted metal howled; then something as big as a beached
freighter moved into view.
Two dull red beams glowing near the top of the high silhouette
swung, flashed crimson and held on me. A siren went off—an ear-
splitting whoop! whoop! WHOOP!
It was an unmanned Bolo Mark II Combat Unit on automated sentry
duty—and its intruder-sensing circuits were tracking me.

The Bolo pivoted heavily; the whoop! whoop! sounded again; the
robot watchdog was bellowing the alarm.
I felt sweat pop out on my forehead. Standing up to a Mark II Bolo
without an electropass was the rough equivalent of being penned in
with an ill-tempered dinosaur. I looked toward the Primary
blockhouse: too far. The same went for the perimeter fence. My best
bet was back to the tunnel mouth. I turned to sprint for it, hooked a
foot on a slab and went down hard....
I got up, my head ringing, tasting blood in my mouth. The chipped
pavement seemed to rock under me. The Bolo was coming up fast.
Running was no good, I had to have a better idea.
I dropped flat and switched my suit control to maximum insulation.
The silvery surface faded to dull black. A two-foot square of tattered
paper fluttered against a projecting edge of concrete; I reached for it,
peeled it free, then fumbled with a pocket flap, brought out a
permatch, flicked it alight. When the paper was burning well, I tossed
it clear. It whirled away a few feet, then caught in a clump of grass.
"Keep moving, damn you!" I whispered. The swearing worked. The
gusty wind pushed the paper on. I crawled a few feet and pressed
myself into a shallow depression behind the slab. The Bolo churned
closer; a loose treadplate was slapping the earth with a rhythmic
thud. The burning paper was fifty feet away now, a twinkle of orange
light in the deep twilight.
At twenty yards, looming up like a pagoda, the Bolo halted, sat
rumbling and swiveling its rust-streaked turret, looking for the
radiating source its IR had first picked up. The flare of the paper
caught its electronic attention. The turret swung, then back. It was
puzzled. It whooped again, then reached a decision.
Ports snapped open. A volley of anti-personnel slugs whoofed into
the target; the scrap of paper disappeared in a gout of tossed dirt.
I hugged the ground like gold lame hugs a torch singer's hip and
waited; nothing happened. The Bolo sat, rumbling softly to itself.
Then I heard another sound over the murmur of the idling engine, a
distant roaring, like a flight of low-level bombers. I raised my head
half an inch and took a look. There were lights moving beyond the
field—the paired beams of a convoy approaching from the town.

The Bolo stirred, moved heavily forward until it towered over me no


more than twenty feet away. I saw gun ports open high on the
armored facade—the ones that housed the heavy infinite repeaters.
Slim black muzzles slid into view, hunted for an instant, then
depressed and locked.
They were bearing on the oncoming vehicles that were spreading out
now in a loose skirmish line under a roiling layer of dust. The
watchdog was getting ready to defend its territory—and I was caught
in the middle. A blue-white floodlight lanced out from across the field,
glared against the scaled plating of the Bolo. I heard relays click
inside the monster fighting machine, and braced myself for the
thunder of her battery....
There was a dry rattle.
The guns traversed, clattering emptily. Beyond the fence the
floodlight played for a moment longer against the Bolo, then moved
on across the ramp, back, across and back, searching....
Once more the Bolo fired its empty guns. Its red IR beams swept the
scene again; then relays snicked, the impotent guns retracted, the
port covers closed.
Satisfied, the Bolo heaved itself around and moved off, trailing a stink
of ozone and ether, the broken tread thumping like a cripple on a
stair.
I waited until it disappeared in the gloom two hundred yards away,
then cautiously turned my suit control to vent off the heat. Full
insulation could boil a man in his own gravy in less than half an hour.
The floodlight had blinked off now. I got to my hands and knees and
started toward the perimeter fence. The Bolo's circuits weren't tuned
as fine as they should have been; it let me go.

There were men moving in the glare and dust, beyond the rusty lace-
work that had once been a chain-link fence. They carried guns and
stood in tight little groups, staring across toward the blockhouse.
I moved closer, keeping flat and avoiding the avenues of yellowish
light thrown by the headlamps of the parked vehicles—halftracks,
armored cars, a few light manned tanks.
There was nothing about the look of this crowd that impelled me to
leap up and be welcomed. They wore green uniforms, and half of
them sported beards. What the hell: had Castro landed in force?
I angled off to the right, away from the big main gate that had been
manned day and night by guards with tommyguns. It hung now by
one hinge from a scarred concrete post, under a cluster of dead
polyarcs in corroded brackets. The big sign that had read GLENN
AEROSPACE CENTER—AUTHORIZED PERSONNEL ONLY lay face down
in hip-high underbrush.
More cars were coming up. There was a lot of talk and shouting; a
squad of men formed and headed my way, keeping to the outside of
the fallen fence.
I was outside the glare of the lights now. I chanced a run for it, got
over the sagged wire and across a potholed blacktop road before
they reached me. I crouched in the ditch and watched as the detail
dropped men in pairs at fifty-yard intervals.
Another five minutes and they would have intercepted me—along
with whatever else they were after.
I worked my way back across an empty lot and found a strip of lesser
underbrush lined with shaggy trees, beneath which a patch of
cracked sidewalk showed here and there.
Several things were beginning to be a little clearer now: The person
who had pushed the button to bring me out of stasis hadn't been
around to greet me, because no one pushed it. The automatics,
triggered by some malfunction, had initiated the recovery cycle.
The system's self-contained power unit had been designed to
maintain a star-ship crewman's minimal vital functions indefinitely, at
reduced body temperature and metabolic rate. There was no way to
tell exactly how long I had been in the tank. From the condition of
the fence and the roads, it had been more than a matter of weeks—
or even months.
Had it been a year ... or more? I thought of Ginny and the boy,
waiting at home—thinking the old man was dead, probably. I'd
neglected them before for my work, but not like this....
Our house was six miles from the base, in the foothills on the other
side of town. It was a long walk, the way I felt—but I had to get
there.

II
Two hours later, I was clear of the town, following the river bank
west.
I kept having the idea that someone was following me. But when I
stopped to listen, there was never anything there; just the still, cold
night, and the frogs, singing away patiently in the low ground to the
south.
When the ground began to rise, I left the road and struck off across
the open field. I reached a wide street, followed it in a curve that
would bring me out at the foot of Ridge Avenue—my street. I could
make out the shapes of low, rambling houses now.
It had been the kind of residential section the local Junior Chamber
members had hoped to move into some day. Now the starlight that
filtered through the cloud cover showed me broken windows, doors
that sagged open, automobiles that squatted on flat, dead tires under
collapsing car shelters—and here and there a blackened, weed-grown
foundation, like a gap in a row of rotting teeth.
The neighborhood wasn't what it had been. How long had I been
away? How long...?
I fell down again, hard this time. It wasn't easy getting up. I seemed
to weigh a hell of a lot for a guy who hadn't been eating regularly. My
breathing was very fast and shallow now, and my skull was getting
ready to split and give birth to a live alligator—the ill-tempered kind.
It was only a few hundred yards more; but why the hell had I picked
a place halfway up a hill?
I heard the sound again—a crackle of dry grass. I got the pistol out
and stood flatfooted in the middle of the street, listening hard.
All I heard was my stomach growling. I took the pistol off cock and
started off again, stopped suddenly a couple of times to catch him
off-guard; nothing. I reached the corner of Ridge Avenue, started up
the slope. Behind me, a stick popped loudly.
I picked that moment to fall down again. Heaped leaves saved me
from another skinned knee. I rolled over against a low fieldstone wall
and propped myself against it. I had to use both hands to cock the
pistol. I stared into the dark, but all I could see were the little lights
whirling again. The pistol got heavy; I put it down, concentrated on
taking deep breaths and blinking away the fireflies.
I heard footsteps plainly, close by. I shook my head, accidentally
banged it against the stone behind me. That helped. I saw him, not
over twenty feet away, coming up the hill toward me, a black-haired
man with a full beard, dressed in odds and ends of rags and furs,
gripping a polished club with a leather thong.
I reached for the pistol, found only leaves, tried again, touched the
gun and knocked it away. I was still groping when I heard a scuffle of
feet. I swung around, saw a tall, wide figure with a mane of
untrimmed hair.
He hit the bearded man like a pro tackle taking out the practice
dummy. They went down together hard and rolled over in a flurry of
dry leaves. The cats were fighting over the mouse; that was my
signal to leave quietly.
I made one last grab for the gun, found it, got to my feet and
staggered off up the grade that seemed as steep now as penthouse
rent. And from down slope, I heard an engine gunned, the clash of a
heavy transmission that needed adjustment. A spotlight flickered,
made shadows dance.
I recognized a fancy wrought-iron fence fronting a vacant lot; that
had been the Adams house. Only half a block to go—but I was losing
my grip fast. I went down twice more, then gave up and started
crawling. The lights were all around now, brighter than ever. My head
split open, dropped off and rolled downhill.
A few more yards and I could let it all go. Ginny would put me in a
warm bed, patch up my scratches, and feed me soup. Ginny would ...
Ginny....

I was lying with my mouth full of dead leaves. I heard running feet,
yells. An engine idled noisily down the block.
I got my head up and found myself looking at chipped brickwork and
the heavy brass hinges from which my front gate had hung. The gate
was gone and there was a large chunk of brick missing. Some
delivery truck had missed his approach.
I got to my feet, took a couple of steps into deep shadow with feet
that felt as though they'd been amputated and welded back on at the
ankle. I stumbled, fetched up against something scaled over with
rust. I held on, blinked and made out the seeping flank of my brand
new '79 Pontiac. There was a crumbled crust of whitish glass lining
the bright-work strip that had framed the rear window.
A fire...?
A footstep sounded behind me, and I suddenly remembered several
things, none of them pleasant. I felt for my gun; it was gone. I
moved back along the side of the car, tried to hold on.
No use. My arms were like unsuccessful pie crust. I slid down among
dead leaves, sat listening to the steps coming closer. They stopped,
and through a dense fog that had sprung up suddenly I caught a
glimpse of a tall white-haired figure standing over me.

Then the fog closed in and swept everything away.

I lay on my back this time, looking across at the smoky yellow light of
a thick brown candle guttering in the draft from a glassless window.
In the center of the room, a few sticks of damp-looking wood heaped
on the cracked asphalt tiles burned with a grayish flame. A thin curl
of acrid smoke rose up to stir cobwebs festooned under ceiling
beams from which wood veneer had peeled away. Light alloy truss-
work showed beneath.
It was a strange scene, but not so strange that I didn't recognize it: it
was my own living room—looking a little different than when I had
seen it last. The odors were different, too; I picked out mildew,
badly-cured leather, damp wool, tobacco....
I turned my head. A yard from the rags I lay on, the white-haired
man, looking older than pharaoh, sat sleeping with his back against
the wall.
The shotgun was gripped in one big, gnarled hand. His head was
tilted back, blue-veined eyelids shut. I sat up, and at my movement
his eyes opened.
He lay relaxed for a moment, as though life had to return from some
place far away. Then he raised his head. His face was hollow and
lined. His white hair was thin. A coarse-woven shirt hung loose across
wide shoulders that had been Herculean once. But now Hercules was
old, old. He looked at me expectantly.
"Who are you?" I said. "Why did you follow me? What happened to
the house? Where's my family? Who owns the bully-boys in green?"
My jaw hurt when I spoke. I put my hand up and felt it gingerly.
"You fell," the old man said, in a voice that rumbled like a
subterranean volcano.
"The understatement of the year, Pop." I tried to get up. Nausea
knotted my stomach.
"You have to rest," the old man said, looking concerned. "Before the
Baron's men come...." He paused, looking at me as though he
expected me to say something profound.
"I want to know where the people are that live here!" My yell came
out as weak as church-social punch. "A woman and a boy...."
He was shaking his head. "You have to do something quick. The
soldiers will come back, search every house—"
I sat up, ignoring the little men driving spikes into my skull. "I don't
give a damn about soldiers! Where's my family? What's happened?" I
reached out and gripped his arm. "How long was I down there? What
year is this?"

He only shook his head. "Come, eat some food. Then I can help you
with your plan."
It was no use talking to the old man; he was senile.
I got off the cot. Except for the dizziness and a feeling that my knees
were made of papier-mache, I was all right. I picked up the hand-
formed candle, stumbled into the hall.
It was a jumble of rubbish. I climbed through, pushed open the door
to my study. There was my desk, the tall bookcase with the glass
doors, the gray rug, the easy chair. Aside from a layer of dust and
some peeling wall paper, it looked normal. I flipped the switch.
Nothing happened.
"What is that charm?" the old man said behind me. He pointed to the
light switch.
"The power's off," I said. "Just habit."
He reached out and flipped the switch up, then down again. "It
makes a pleasing sound."
"Yeah." I picked up a book from the desk; it fell apart in my hands.
I went back into the hall, tried the bedroom door, looked in at heaped
leaves, the remains of broken furniture, an empty window frame. I
went on to the end of the hall and opened the door to the bedroom.
Cold night wind blew through a barricade of broken timbers. The roof
had fallen in, and a sixteen-inch tree trunk slanted through the
wreckage. The old man stood behind me, watching.
"Where is she, damn you?" I leaned against the door frame to swear
and fight off the faintness. "Where's my wife?"
The old man looked troubled. "Come, eat now...."
"Where is she? Where's the woman who lived here?"
He frowned, shook his head dumbly. I picked my way through the
wreckage, stepped out into knee-high brush. A gust blew my candle
out. In the dark I stared at my back yard, the crumbled pit that had
been the barbecue grill, the tangled thickets that had been rose beds
—and a weathered length of boards upended in the earth.
"What the hell's this...?" I fumbled out a permatch, lit my candle,
leaned close and read the crude letters cut into the crumbling wood:
VIRGINIA ANNE JACKSON. BORN JAN. 8 1957. KILL BY THE DOGS
WINTER 1992.

III
The Baron's men came twice in the next three days. Each time the
old man carried me, swearing but too weak to argue, out to a lean-to
of branches and canvas in the woods behind the house. Then he
disappeared, to come back an hour or two later and haul me back to
my rag bed by the fire.
Three times a day he gave me a tin pan of stew, and I ate it
mechanically. My mind went over and over the picture of Ginny, living
on for twelve years in the slowly decaying house, and then—
It was too much. There are some shocks the mind refuses.
I thought of the tree that had fallen and crushed the east wing. An
elm that size was at least fifty to sixty years old—maybe older. And
the only elm on the place had been a two-year sapling. I knew it
well; I had planted it.
The date carved on the headboard was 1992. As nearly as I could
judge another thirty-five years had passed since then at least. My
shipmates—Banner, Day, Mallon—they were all dead, long ago. How
had they died? The old man was too far gone to tell me anything
useful. Most of my questions produced a shake of the head and a few
rumbled words about charms, demons, spells, and the Baron.
"I don't believe in spells," I said. "And I'm not too sure I believe in
this Baron. Who is he?"
"The Baron Trollmaster of Filly. He holds all this country—" the old
man made a sweeping gesture with his arm—"all the way to Jersey."
"Why was he looking for me? What makes me important?"
"You came from the Forbidden Place. Everyone heard the cries of the
Lesser Troll that stands guard over the treasure there. If the Baron
can learn your secrets of power—"
"Troll, hell! That's nothing but a Bolo on automatic!"
"By any name every man dreads the monster. A man who walks in its
shadow has much mana. But the others—the ones that run in a pack
like dogs—would tear you to pieces for a demon if they could lay
hands on you."
"You saw me back there. Why didn't you give me away? And why are
you taking care of me now?"
He shook his head—the all-purpose answer to any question.
I tried another tack: "Who was the rag man you tackled just outside?
Why was he laying for me?"
The old man snorted. "Tonight the dogs will eat him. But forget that.
Now we have to talk about your plan—"
"I've got about as many plans as the senior boarder in Death Row. I
don't know if you know it, Old Timer, but somebody slid the world out
from under me while I wasn't looking."
The old man frowned. I had the thought that I wouldn't like to have
him mad at me, for all his white hair....
He shook his head. "You must understand what I tell you. The
soldiers of the Baron will find you some day. If you are to break the
spell—"
"Break the spell, eh?" I snorted. "I think I get the idea, Pop. You've
got it in your head that I'm a valuable property of some kind. You
figure I can use my supernatural powers to take over this menagerie
—and you'll be in on the ground floor. Well, listen, you old idiot! I
spent sixty years—maybe more—in a stasis tank two hundred feet
underground. My world died while I was down there. This Baron of
yours seems to own everything now. If you think I'm going to get
myself shot bucking him, forget it!"
The old man didn't say anything.
"Things don't seem to be broken up much," I went on. "It must have
been gas, or germ warfare—or fallout. Damn few people around.
You're still able to live on what you can loot from stores; automobiles
are still sitting where they were the day the world ended. How old
were you when it happened, Pop? The war, I mean. Do you
remember it?"
He shook his head. "The world has always been as it is now."
"What year were you born?"
He scratched at his white hair. "I knew the number once. But I've
forgotten."
"I guess the only way I'll find out how long I was gone is to saw that
damned elm in two and count the rings—but even that wouldn't help
much; I don't know when it blew over. Never mind. The important
thing now is to talk to this Baron of yours. Where does he stay?"
The old man shook his head violently. "If the Baron lays his hands on
you, he'll wring the secrets from you on the rack! I know his ways.
For five years I was a slave in the Palace Stables."
"If you think I'm going to spend the rest of my days in this rat nest,
you got another guess on the house! This Baron has tanks, an army.
He's kept a little technology alive. That's the outfit for me—not this
garbage detail! Now, where's this place of his located?"
"The guards will shoot you on sight like a pack-dog!"
"There has to be a way to get to him, old man! Think!"
The old head was shaking again. "He fears assassination. You can
never approach him...." He brightened. "Unless you know a spell of
power?"
I chewed my lip. "Maybe I do at that. You wanted me to have a plan.
I think I feel one coming on. Have you got a map?"
He pointed to the desk beside me. I tried the drawers, found mice,
roaches, moldy money—and a stack of folded maps. I opened one
carefully; faded ink on yellowed paper, falling apart at the creases.
The legend in the corner read: "PENNSYLVANIA 40M:1. Copyright
1970 by ESSO Corporation."
"This will do, Pop," I said. "Now, tell me all you can about this Baron
of yours."
"You'll destroy him?"
"I haven't even met the man."
"He is evil."
"I don't know; he owns an army. That makes up for a lot...."

After three more days of rest and the old man's stew, I was back to
normal—or near enough. I had the old man boil me a tub of water
for a bath and a shave. I found a serviceable pair of synthetic fiber
long-johns in a chest of drawers, pulled them on and zipped the
weather suit over them, then buckled on the holster I had made from
a tough plastic.
"That completes my preparations, Pop," I said. "It'll be dark in
another half hour. Thanks for everything."
He got to his feet, a worried look on his lined face, like a father the
first time Junior asks for the car.
"The Baron's men are everywhere."
"If you want to help, come along and back me up with that shotgun
of yours." I picked it up. "Have you got any shells for this thing?"
He smiled, pleased now. "There are shells—but the magic is gone
from many."
"That's the way magic is, Pop. It goes out of things before you
notice."
"Will you destroy the Great Troll now?"
"My motto is let sleeping trolls lie. I'm just paying a social call on the
Baron."
The joy ran out of his face like booze from a dropped jug.
"Don't take it so hard, Old Timer. I'm not the fairy prince you were
expecting. But I'll take care of you—if I make it."
I waited while he pulled on a moth-eaten mackinaw. He took the
shotgun and checked the breech, then looked at me.
"I'm ready," he said.
"Yeah," I said. "Let's go...."

The Baronial palace was a forty-story slab of concrete and glass that
had been known in my days as the Hilton Garden East. We made it in
three hours of groping across country in the dark, at the end of
which I was puffing but still on my feet. We moved out from the
cover of the trees and looked across a dip in the ground at the lights,
incongruously cheerful in the ravaged valley.
"The gates are there—" the old man pointed—"guarded by the Great
Troll."
"Wait a minute. I thought the Troll was the Bolo back at the Site."
"That's the Lesser Troll. This is the Great One."
I selected a few choice words and muttered them to myself. "It would
have saved us some effort if you'd mentioned this Troll a little sooner,
Old Timer. I'm afraid I don't have any spells that will knock out a
Mark II, once it's got its dander up."
He shook his head. "It lies under enchantment. I remember the day
when it came, throwing thunderbolts. Many men were killed. Then
the Baron commanded it to stand at his gates to guard him."
"How long ago was this, Old Timer?"
He worked his lips over the question. "Long ago," he said finally.
"Many winters."
"Let's go take a look."
We picked our way down the slope, came up along a rutted dirt road
to the dark line of trees that rimmed the palace grounds. The old
man touched my arm.
"Softly here. Maybe the Troll sleeps lightly...."
I went the last few yards, eased around a brick column with a dead
lantern on top, stared across fifty yards of waist-high brush at a dark
silhouette outlined against the palace lights.
Cables, stretched from trees outside the circle of weeds, supported a
weathered tarp which drooped over the Bolo. The wreckage of a
helicopter lay like a crumpled dragonfly at the far side of the ring.
Nearer, fragments of a heavy car chassis lay scattered. The old man
hovered at my shoulder.
"It looks as though the gate is off limits," I hissed. "Let's try farther
along."
He nodded. "No one passes here. There is a second gate, there." He
pointed. "But there are guards."
"Let's climb the wall between gates."
"There are sharp spikes on top the wall. But I know a place, farther
on, where the spikes have been blunted."
"Lead on, Pop."
Half an hour of creeping through wet brush brought us to the spot
we were looking for. It looked to me like any other stretch of eight-
foot masonry wall overhung with wet poplar trees.
"I'll go first," the old man said, "to draw the attention of the guard."
"Then who's going to boost me up? I'll go first."
He nodded, cupped his hands and lifted me as easily as a sailor lifting
a beer glass. Pop was old—but he was nobody's softie.
I looked around, then crawled up, worked my way over the corroded
spikes, dropped down on the lawn.
Immediately I heard a crackle of brush. A man stood up not ten feet
away. I lay flat in the dark trying to look like something that had been
there a long time....
I heard another sound, a thump and a crashing of brush. The man
before me turned, disappeared in the darkness. I heard him beating
his way through shrubbery; then he called out, got an answering
shout from the distance.
I didn't loiter. I got to my feet and made a sprint for the cover of the
trees along the drive.

IV
Flat on the wet ground, under the wind-whipped branches of an
ornamental cedar, I blinked the fine misty rain from my eyes, waiting
for the half-hearted alarm behind me to die down.
There were a few shouts, some sounds of searching among the
shrubbery. It was a bad night to be chasing imaginary intruders in
the Baronial grounds. In five minutes, all was quiet again.
I studied the view before me. The tree under which I lay was one of
a row lining a drive. It swung in a graceful curve, across a smooth
half-mile of dark lawn, to the tower of light that was the Palace of the
Baron of Filly. The silhouetted figures of guards and late-arriving
guests moved against the gleam from the collonaded entrance. On a
terrace high above, dancers twirled under colored lights. The faint
glow of the repellor field kept the cold rain at a distance. In a lull in
the wind, I heard music, faintly. The Baron's weekly Grand Ball was in
full swing.
I saw shadows move across the wet gravel before me, then heard
the purr of an engine. I hugged the ground and watched a long
svelte Mercedes—about a '68 model, I estimated—barrel past.
The mob in the city ran in packs like dogs, but the Baron's friends did
a little better for themselves.
I got to my feet and moved off toward the palace, keeping well in the
shadows. When the drive swung to the right to curve across in front
of the building, I left it, went to hands and knees and followed a
trimmed privet hedge, past dark rectangles of formal garden to the
edge of a secondary pond of light from the garages. I let myself
down on my belly and watched the shadows that moved on the
graveled drive.
There seemed to be two men on duty—no more. Waiting around
wouldn't improve my chances. I got to my feet, stepped out into the
drive and walked openly around the corner of the gray fieldstone
building into the light.
A short, thickset man in greasy Baronial green looked at me
incuriously. My weather suit looked enough like ordinary coveralls to
get me by—at least for a few minutes. A second man, tilted back
against the wall in a wooden chair, didn't even turn his head.
"Hey!" I called. "You birds got a three-ton jack I can borrow?"
Shorty looked me over sourly. "Who you drive for, Mac?"
"The High Duke of Jersey. Flat. Left rear. On a night like this. Some
luck."
"The Jersey can't afford a jack?"

I stepped over the short man, prodded him with a forefinger. "He
could buy you and gut you on the altar any Saturday night of the
week, low-pockets. And he'd get a kick out of doing it. He's like that."
"Can't a guy crack a harmless joke without somebody talks about
altar-bait? You wanna jack, take a jack."
The man in the chair opened one eye and looked me over. "How long
you on the Jersey payroll?" he growled.
"Long enough to know who handles the rank between Jersey and
Filly." I yawned, looked around the wide, cement floored garage,
glanced over the four heavy cars with the Filly crest on their sides.
"Where's the kitchen? I'm putting a couple of hot coffees under my
belt before I go back out into that."
"Over there. A flight up and to your left. Tell the cook Pintsy invited
you."
"I tell him Jersey sent me, low-pockets." I moved off in a dead
silence, opened the door and stepped up into spicy-scented warmth.
A deep carpet—even here—muffled my footsteps. I could hear the
clash of pots and crockery from the kitchen a hundred feet distant
along the hallway. I went along to a deep-set doorway ten feet from
the kitchen, tried the knob and looked into a dark room. I pushed the
door shut and leaned against it, watching the kitchen. Through the
woodwork I could feel the thump of the bass notes from the
orchestra blasting away three flights up. The odors of food—roast
fowl, baked ham, grilled horsemeat—curled under the kitchen door
and wafted under my nose. I pulled my belt up a notch and tried to
swallow the dryness in my throat. The old man had fed me a half a
gallon of stew, before we left home, but I was already working up a
fresh appetite.
Five slow minutes passed. Then the kitchen door swung open and a
tall round-shouldered fellow with a shiny bald scalp stepped into
view, a tray balanced on the spread fingers of one hand. He turned,
the black tails of his cutaway swirling, called something behind him
and started past me. I stepped out, clearing my throat. He shied,
whirled to face me. He was good at his job: The two dozen tiny
glasses on the tray stood fast. He blinked, got an indignant remark
ready—
I showed him the knife the old man had lent me—a bone-handled job
with a six-inch switch-blade. "Make a sound and I'll cut your throat," I
said softly. "Put the tray on the floor."
He started to back. I brought the knife up. He took a good look,
licked his lips, crouched quickly and put the tray down.
"Turn around."
I stepped in and chopped him at the base of the neck with the edge
of my hand. He folded like a two-dollar umbrella.
I wrestled the door open and dumped him inside, paused a moment
to listen. All quiet. I worked his black coat and trousers off, unhooked
the stiff white dickey and tie. He snored softly. I pulled the clothes on
over the weather suit. They were a fair fit. By the light of my pencil
flash, I cut down a heavy braided cord hanging by a high window,
used it to truss the waiter's hands and feet together behind him.
There was a small closet opening off the room. I put him in it, closed
the door and stepped back into the hall. Still quiet. I tried one of the
drinks. It wasn't bad.
I took another, then picked up the tray and followed the sounds of
music.
The grand ballroom was a hundred yards long, fifty wide, with walls
of rose, gold and white, banks of high windows hung with crimson
velvet, a vaulted ceiling decorated with cherubs and a polished acre
of floor on which gaudily gowned and uniformed couples moved in
time to the heavy beat of the traditional fox-trot. I moved slowly
along the edge of the crowd, looking for the Baron.
A hand caught my arm and hauled me around. A glass fell off my
tray, smashed on the floor.
A dapper little man in black and white headwaiter's uniform glared up
at me.
"What do you think you're doing, cretin?" he hissed. "That's the
genuine ancient stock you're slopping on the floor." I looked around
quickly; no one else seemed to be paying any attention.
"Where are you from?" he snapped. I opened my mouth—
"Never mind, you're all the same." He waggled his hands disgustedly.
"The field-hands they send me—a disgrace to the Black. Now, you!
Stand up! Hold your tray proudly, gracefully! Step along daintily, not
like a knight taking the field! And pause occasionally—just on the
chance that some noble guest might wish to drink."
"You bet, pal," I said. I moved on, paying a little more attention to
my waiting. I saw plenty of green uniforms; pea green, forest green,
emerald green—but they were all hung with braid and medals.
According to Pop, the Baron affected a spartan simplicity. The
diffidence of absolute power.
There were high white and gold doors every few yards along the side
of the ballroom. I spotted one standing open and sidled toward it. It
wouldn't hurt to reconnoiter the area.
Just beyond the door, a very large sentry in a bottle-green uniform
almost buried under gold braid moved in front of me. He was dressed
like a toy soldier, but there was nothing playful about the way he
snapped his power gun to the ready. I winked at him.
"Thought you boys might want a drink," I hissed. "Good stuff."
He looked at the tray, licked his lips. "Get back in there, you fool," he
growled. "You'll get us both hung."
"Suit yourself, pal." I backed out. Just before the door closed
between us, he lifted a glass off the tray.

I turned, almost collided with a long lean cookie in a powder-blue


outfit complete with dress sabre, gold frogs, leopard-skin facings, a
pair of knee-length white gloves looped under an epaulette, a pistol
in a fancy holster and an eighteen-inch swagger stick. He gave me
the kind of look old maids give sin.
"Look where you're going, swine," he said in a voice like a pine board
splitting.
"Have a drink, Admiral," I suggested.
He lifted his upper lip to show me a row of teeth that hadn't had their
annual trip to the dentist lately. The ridges along each side of his
mouth turned greenish white. He snatched for the gloves on his
shoulder, fumbled them; they slapped the floor beside me.
"I'd pick those up for you, Boss," I said, "But I've got my tray...."
He drew a breath between his teeth, chewed it into strips and
snorted it back at me, then snapped his fingers and pointed with his
stick toward the door behind me.
"Through there, instantly!" It didn't seem like the time to argue; I
pulled it open and stepped through.
The guard in green ducked his glass and snapped to attention when
he saw the baby-blue outfit. My new friend ignored him, made a curt
gesture to me. I got the idea, trailed along the wide, high, gloomy
corridor to a small door, pushed through it into a well-lit tile-walled
latrine. A big-eyed slave in white ducks stared.
Blue-boy jerked his head. "Get out!" The slave scuttled away. Blue-
boy turned to me.
"Strip off your jacket, slave! Your owner has neglected to teach you
discipline."
I looked around quickly, saw that we were alone.
"Wait a minute while I put the tray down, corporal," I said. "We don't
want to waste any of the good stuff." I turned to put the tray on a
soiled linen bin, caught a glimpse of motion in the mirror.
I ducked, and the nasty-looking little leather quirt whistled past my
ear, slammed against the edge of a marble-topped lavatory with a
crack like a pistol shot. I dropped the tray, stepped in fast and threw
a left to Blue-boy's jaw that bounced his head against the tiled wall. I
followed up with a right to the belt buckle, then held him up as he
bent over, gagging, and hit him hard under the ear.
I hauled him into a booth, propped him up and started shedding the
waiter's blacks.

V
I left him on the floor wearing my old suit, and stepped out into the
hall.
I liked the feel of his pistol at my hip. It was an old fashioned .38, the
same model I favored. The blue uniform was a good fit, what with
the weight I'd lost. Blue-boy and I had something in common after
all.
The latrine attendant goggled at me. I grimaced like a quadruple
amputee trying to scratch his nose and jerked my head toward the
door I had come out of. I hoped the gesture would look familiar.
"Truss that mad dog and throw him outside the gates," I snarled. I
stamped off down the corridor, trying to look mad enough to
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!

textbookfull.com

You might also like