100% found this document useful (1 vote)
60 views

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane All Chapters Instant Download

Introduction

Uploaded by

hanzekewinur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
60 views

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane All Chapters Instant Download

Introduction

Uploaded by

hanzekewinur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

A Web Based Introduction to Programming Essential


Algorithms Syntax and Control Structures Using Php
Html and Mariadb MySQL Mike O’Kane

https://textbookfull.com/product/a-web-based-introduction-
to-programming-essential-algorithms-syntax-and-control-
structures-using-php-html-and-mariadb-mysql-mike-okane/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

PHP and MySQL for Dynamic Web Sites Fifth Edition Ullman

https://textbookfull.com/product/php-and-mysql-for-dynamic-web-sites-
fifth-edition-ullman/

textboxfull.com

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/

textboxfull.com

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/

textboxfull.com

Essential algorithms a practical approach to computer


algorithms using Python and C Second Edition Rod Stephens

https://textbookfull.com/product/essential-algorithms-a-practical-
approach-to-computer-algorithms-using-python-and-c-second-edition-rod-
stephens/
textboxfull.com
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/

textboxfull.com

Problem Solving in Data Structures Algorithms Using C


Programming Interview Guide First Edition Hemant Jain

https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-first-edition-hemant-
jain/
textboxfull.com

Problem Solving in Data Structures Algorithms Using C


Programming Interview Guide 1st Edition Hemant Jain

https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-1st-edition-hemant-
jain/
textboxfull.com

Learning PHP, MySQL & JavaScript, 6th Edition Robin Nixon

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

textboxfull.com

Introduction to Java Programming and Data Structures


Comprehensive Version Y Daniel Liang

https://textbookfull.com/product/introduction-to-java-programming-and-
data-structures-comprehensive-version-y-daniel-liang/

textboxfull.com
A Web-Based Introduction
to Programming

2
A Web-Based Introduction
to Programming

3
Essential Algorithms, Syntax,
and Control Structures Using PHP, HTML,
and MariaDB/MySQL

Fourth Edition

Mike O'Kane

4
Copyright © 2017
Mike O'Kane
All Rights Reserved.

Library of Congress Cataloging-in-Publication Data

Names: O'Kane, Mike, 1953- author.


Title: A web-based introduction to programming : essential algorithms,
syntax, and control structures using PHP, HTML, and MariaDB/MySQL / Mike
O'Kane.
Description: Durham, North Carolina : Carolina Academic Press, [2017] |
Includes bibliographical references and index.
Identifiers: LCCN 2017017694 | ISBN 9781531002749 (alk. paper)
Subjects: LCSH: Computer software--Development. | Internet programming. |
Computer programming--Web-based instruction. | PHP (Computer program
language) | XHTML (Document markup language)
Classification: LCC QA76.76.D47 O43 2017 | DDC 005.3--dc23
LC record available at https://lccn.loc.gov/2017017694

eISBN 978-1-53100-707-2

Carolina Academic Press, LLC


700 Kent Street
Durham, North Carolina 27701
Telephone (919) 489-7486
Fax (919) 493-5668

www.cap-press.com

Printed in the United States of America.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any
means, electronic, mechanical, recording or otherwise, without the prior written permission of the author.

Please note: The information in this book is provided for instructional value and distributed on an “as is” basis,
without warranty. While every precaution has been taken in the preparation of the book, neither the author nor
Carolina Academic Press shall have any liability to any person or entity with respect to any loss or damage caused
by or alleged to be caused, directly or indirectly, by the instructions contained in this book or by the programs or
applications that are listed in, or provided as supplements to, this book.

Macintosh®, Mac OS®, Safari, and iOS® are registered trademarks of Apple, Inc. in the United States and other
countries. Windows® and Windows Mobile® are registered trademarks of Microsoft Corporation in the United
States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other
countries. MySQL® is a registered trademark of Oracle Corporation and/or its affiliates. MariaDB® is a registered
trademark of MariaDB Corporation Ab. Mozilla® and Firefox® are registered trademarks of the Mozilla
Foundation. Joomla!® is trademarked by Open Source Matters. Apache® is a trademark of the Apache Software
Foundation. XAMPP and Apache Friends are registered trademarks of BitRock. The WordPress® trademark is
owned by the WordPress Foundation. Android® and Google Chrome® are trademarks of Google Inc. The Drupal®
trademark is owned and controlled by Dries Buytaert. BlackBerry® is a trademark of Blackberry. All product
names identified in this book are trademarks or registered trademarks, and are the properties of their respective
companies. We have used these names in an editorial fashion only, and to the benefit of the owner, with no

5
intention of infringing the trademark.

6
To my dear mother and father,
thank you for the love and light that you bestowed on us.

7
Contents

Preface
Acknowledgments
About the Author

Chapter 1 · Introducing Computer Programming


Introduction
What Is a Computer Program?
What Do Programmers Do?
The Software Development Life Cycle
The Importance of Writing and Communicating
What Are Programming Languages?
Compilers and Interpreters
So Many Languages!
Standalone and Network Applications
Markup Languages
Combining Markup and Programming Languages
Summary
Chapter 1 Review Questions

Chapter 2 · Client/Server Applications—Getting Started


Introduction
Client/Server Design in Web Applications
Working with Files and Folders
Locating Files and Folders on Computers Running a Windows Operating System
Locating Files and Folders on the Internet
Internet Naming Conventions for Files and Folders
Working with a Local Web Server
What Languages Will I Use?
What Software Will I Need?
Installing a Text Editor
Installing One or More Web Browsers
Installing Your Web Server
Using Your Web Server
Using URLs with Your Web Server
Always Use URLs to Run Your Web Applications!
Where to Save Your Work Files
The Importance of Frequent Backups
Creating an HTML Document
Creating a PHP program

8
Creating an Interactive HTML and PHP Program
Summary
Chapter 2 Review Questions
Chapter 2 Code Exercises

Chapter 3 · Program Design—From Requirements to Algorithms


Introduction
What Are Instructions?
Common Characteristics of Instructions
Sequence, Selection and Repetition Structures
A Programming Example
Creating an Input, Processing, Output (IPO) chart
Designing the User Interface
Developing an Algorithm
A Smoking Calculator
Coding the Application
Summary
Chapter 3 Review Questions
Chapter 3 Code Exercises

Chapter 4 · Basics of Markup—Creating a User Interface with HTML


Introduction
A Short History of HTML
Introducing HTML Tags
Ignoring White Space
More HTML Tags
Introducing HTML Tables
Using HTML Tables to Layout Web Pages
Other HTML Tags
Deprecated HTML Tags
Introducing Style Sheets
Multiple Styles for a Single Tag
Selecting Colors for Fonts and Backgrounds
Referencing a Style Sheet in Your HTML Document
Applying a Style Sheet to Multiple Pages
Interactive User Interfaces
Creating HTML Forms
Using HTML Forms to Obtain User Input
Using HTML Tables to Line Up Prompt and Input Boxes
Problems with Form Submission
Drop Down Lists
Combining Textboxes and Drop Down Lists
Other Types of Input
Stylesheets and Forms

9
Summary
Chapter 4 Review Questions
Chapter 4 Code Exercises

Chapter 5 · Creating a Working Program—Basics of PHP


Introduction
Why PHP?
Working with HTML and PHP
Important Features of Client/Server Programs
Receiving Input from a Form — wage2.php
Processing the Smoking Survey — smoking.php
PHP — General Guidelines and Syntax
Arithmetic Expressions
Using Arithmetic Functions
White Space in PHP Files
Generating Character Strings from PHP
Including Double Quotes in Character Strings
Using Multiple PHP Sections
Using the number_format() Function to Display Numbers to a Specific Number of Places
Including Calls to PHP Functions inside PHP Print Statements
String Concatenation and the Concatenation Operator
The PHP Echo Statement
Finding Syntax Errors
Finding Logical Errors
Summary
Chapter 5 Review Questions
Chapter 5 Code Exercises

Chapter 6 · Persistence — Saving and Retrieving Data


Introduction
The Difference Between Persistent and Transient Data
Files and Databases
Working with a Text File
Closing a Text File
Reading Data from a Text File
PHP Functions to Read Data from a Text File
Writing Data to a Text File
PHP Functions to Write Data to a Text File
Be Careful to Avoid Security Holes!
Using Escape Characters
Escape Characters and HTML Tags
Using PHP to Append Data to Files
PHP Functions to Append Data to a Text File
Processing Files that Contain Complete Records on Each Line

10
PHP Functions to Parse a Delimited Character String
Processing a File with Multiple Records
Appending Records to a File
Working with Multiple Files
Summary
Chapter 6 Review Questions
Chapter 6 Code Exercises

Chapter 7 · Programs that Choose — Introducing Selection Structures


Introduction
Introducing IF and IF..ELSE Structures
Introducing Flow Charts
Boolean Expressions and Relational Operators
Selection Using the IF Structure
Testing Threshold Values
Selection Using the IF..ELSE Structure
When to Use Braces in IF..ELSE Statements
Creating a Program with Multiple but Independent Selection Structures
Comparing Strings — Testing for a Correct Password
Ignoring the Case of a Character String
Providing a Selective Response
Using Selection to Construct a Line of Output
Summary
Chapter 7 Review Questions
Chapter 7 Code Exercises

Chapter 8 · Multiple Selection, Nesting, ANDs and ORs


Introduction
Introducing the Logical Operators AND and OR
Introducing the NOT Operator
Validating User Input
Using A Nested Selection Structure to Validate Input
Designing Applications with Nested Selection Structures
Use of Braces in Nested Selection Structures
Chaining Related Selection Structures
Additional Input Validation Using Chained Selection Structures
More about Input Validation: Using the trim() Function
When to Use AND or OR? Be Careful with Your Logic!
The Challenge of Software Testing
A Special Case: The Switch Statement
More Examples in the Samples Folder
Some Words of Encouragement
Summary
Chapter 8 Review Questions

11
Chapter 8 Code Exercises

Chapter 9 · Programs that Count — Harnessing the Power of Repetition


Introduction
Controlling a Loop by Counting
Coding a FOR Loop in PHP
General Syntax of a FOR Loop
Including the Counting Variable in Your Loop Statements
Using a Variable to Control the Loop Condition
Converting from Celsius to Fahrenheit
Changing the Increment Value
Using Loops with HTML Tables
Allowing the User to Control the Loop
Improving Processing Efficiency
Using Loops to “Crunch Numbers”
Using a Loop to Accumulate a Total
Finding the Total and Average from a File of Numbers
Finding the Highest and Lowest Values in a Series
Performing Multiple Operations on a File of Numbers
Nesting IF..ELSE Structures to Customize Output from a Loop
Loops within Loops — Creating a Bar Chart
Selecting from a List of Data Files
Summary
Chapter 9 Review Questions
Chapter 9 Code Exercises

Chapter 10 · “While NOT End-Of-File”—Introducing Event-Controlled Loops


Introduction
Characteristics of WHILE Loops
The Structure of WHILE Loops
An Algorithm to Process Files of Unknown Length
Using a WHILE Loop to Process a File of Scores
Including Selection Structures Inside a WHILE Loop
Using a WHILE Loop to Count, Sum and Average Data
Using a WHILE Loop to Process a File of Records
Processing Weekly Wages from a File of Timesheet Records
Processing Selected Records from a File of Timesheet Records
Processing Selected Fields from a File of Records
Processing a File of Survey Data
Using DO..WHILE or REPEAT..UNTIL Loops
Summary
Chapter 10 Review Questions
Chapter 10 Code Exercises

12
Chapter 11 · Structured Data — Working with Arrays
Introduction
What Is an Array?
Working with Array Elements
Extending an Array
Displaying Array Values
Receiving Scores into an Array from an HTML Form
Arrays of Strings
How Large Is the Array?
Why Do Array Indices Begin with 0 and Not 1?
Using FOR Loops with Arrays
Using the sizeof() Function to Control a FOR Loop
Summing and Averaging the Values in an Array
Counting Selected Values in an Array
Multiple Operations on an Array
Reading Data from a File into an Array
Reading Data into an Array from a File of Unknown Length
Using [] with no Index Value
Reading Selected Data from a File into an Array
Reading Data from a File into Multiple Arrays
Reading Selected Data from a File of Records into an Array
More About the explode() and list() Functions
A Special Loop for Processing Arrays — FOREACH
Multi-Dimensional Arrays
Summary
Chapter 11 Review Questions
Chapter 11 Code Exercises

Chapter 12 · Associative Arrays


Introduction
Using a Variable to Reference the Key of an Associative Array
Using Associative Arrays as Lookups
Using the array() Function to Create Associative Arrays
Associative Arrays and the FOREACH Loop
More about the $_POST Array
Using the isset() Function to Combine a Web Form with the Form Processing Code in a Single Page
Web Sessions and the $_SESSION Array
Adding Code to Manage a Web Session
Creating, Initializing and Modifying Session Variables
Validating $_SESSION and $_POST Arrays
Revisiting the Same Page in a Web Session
Summary
Chapter 12 Review Questions

13
Chapter 12 Code Exercises

Chapter 13 · Program Modularity — Working with Functions


Introduction
Using Functions
Understanding Function Arguments
Receiving Values from a Function
Researching Available Functions
Reasons to Use Pre-Defined Functions
Using die() or exit() to Terminate an Application
Creating Your Own Functions
Where Do I Put My Functions?
Creating a Library of Functions
Including Functions from External Files
Using the Same Functions in Different Programs
Functions Calling Functions
Learning to Think Beyond Specific Applications
More about Include Files
Summary
Chapter 13 Review Questions
Chapter 13 Code Exercises

Chapter 14 · Connecting to a Database — Working with MySQL


Introduction
What Is a Relational Database?
The Relational Database Management System (RDBMS)
Structured Query Language — MySQL
Starting Your MySQL Server
Configuring MySQL for Use with This Textbook
Three Ways to Work with MySQL
Working with PHP and MySQL
Using PHP to Open and Close a Connection to a MySQL Server
Using the MySQL SELECT Query
Selecting Specific Records
Relational Operators in MySQL
The Logical Operators AND and OR
Ordering Your Query Results
Viewing Your Query Results
Using an HTML Table to Display the Query Results
Putting It All Together
Using Input from an HTML Form to Construct a Query
Processing Queries with a Single Result
Performing Calculations with the Result Set
Performing Aggregate Operations on MySQL Queries

14
Performing JOIN Operations on Multiple Tables
Using INSERT to Add Records to a Table
Using UPDATE to Modify a Record
Removing a Record
Storing MySQL Connection Data in an Include File
Creating, Dropping, and Altering Databases and Tables
Summary
Chapter 14 Review Questions
Chapter 14 Code Exercises

Chapter 15 · Introduction to Object-Oriented Programming


Introduction
What is an Object?
Creating and Using Instances of a Class
Using Employee Objects in an Application
Defining an Object
Coding the Object Class
Creating and Using Instances of an Object Class
The Class Constructor Method
Method Overloading
Why do Objects Matter?
Object Design and Inheritance
Abstract Classes and Methods
Method Over-riding
Polymorphism
OOP and Databases
OOP Development
OOP Languages
Summary
Chapter 15 Review Questions
Chapter 15 Code Exercises

Chapter 16 · Where to Go from Here . . .


Introduction
Moving Forward with PHP and HTML
More about PHP
PHP and Other Languages
XHTML and XML
Client Side Processing with Javascript and Ajax
The Importance of OOP
IDE's, Modeling Languages and Frameworks
Client/Server and Server/Server Programming
Mobile Applications
Digital Media

15
Graphical User Interfaces and Interface Design
Web Design and Content Management
Database Programming and SQL
In Summary: Follow Your Heart!

Appendix A · Data Representation and Formats


Introduction
Storing Data in Bits and Bytes
How Multimedia Data Is Represented in Binary
How Numeric Values Are Represented in Binary
How Plain Text Is Represented in Binary
How Source Code and Markup Code Is Represented in Binary
How Program Instructions Are Represented in Binary
How Memory Addresses Are Represented in Binary
What Else Can Be Represented in Binary?

Appendix B · Files, Folders, Addressing Schemes, and Command Line Arguments


File Types and File Extensions
Disk and Disk Drives
Files and File Folders (Directories)
Naming Files and Folders
File Addresses in Windows and on the Web
Relative Addresses in Windows
Relative Addresses on the Internet
Using Relative Web Addresses in HTML Code
Managing Files at the Command Line
Introduction to MS DOS Commands
Recalling Previous Commands
Use Double Quotes when Paths Include Spaces
Printing the Contents of the Console Window
Creating Batch Files
Unix Commands

Appendix C · Installing and Running Your Standalone Web Server


Using an Active Web Server
Problems Using Your Web Server
Advanced Users

Appendix D · Debugging Your Code


Problems Viewing Your HTML or PHP Programs
Problems with HTML Layout
Locating PHP Syntax Errors
Common PHP Syntax Errors
Common Logical Errors

16
Appendix E · More about HTML and CSS
Useful HTML References
Useful CSS References
Inline Styles and Internal Style Sheets
Deprecated HTML Tags
Frequently Asked Questions Regarding HTML Tags

Appendix F · More about PHP Functions and Data Types


Useful PHP References
More about PHP Functions and Data Types
Standard PHP Array Functions
Standard PHP File Functions
Standard PHP Math Functions
Standard PHP String Functions
PHP Data Types

Appendix G · Additional PHP Operators and Control Structures


Shortcut Operators
Switch Structure
Another Loop Structure: DO..WHILE
Multi-Dimensional Arrays
Ragged Arrays
Multi-Dimensional Associative Arrays

Index

17
Preface

The problem I have tried to solve with this textbook is, quite simply, how to effectively introduce general
programming concepts to students who have never programmed before. Perhaps like me, you have found yourself
frustrated by textbooks that try to cover too much too fast, make inappropriate assumptions about what a student
already knows, or take sudden leaps in complexity when providing examples and exercises.
I believe that the purpose of an introductory programming course is to help students gain confidence and
develop their understanding of basic logic, syntax, and problem-solving. They do not need to learn all aspects of a
language or even learn best practices—these are topics for the next course level. The question is: how to provide
the kind of hands-on experience that supports active learning without overwhelming the beginning student with
too much syntactical and programmatic detail?
I have tried many approaches over the years before settling on a Web-based approach, using PHP, CSS, and
HTML code to develop small, interactive Web applications. This approach has proved very successful. Many
students report how much they enjoy the course, how much they have learned, and how well the material has
served them in subsequent courses and in their professional life. I also hear from many students who tell me that
the course positively changed their opinion of programming as a career or subject of interest, which is most
gratifying.
Some instructors may have concerns that my coverage of the PHP and HTML is insufficient. The book uses a
small number of HTML tags, CSS rules, and PHP functions, and employs some arbitrary conventions to simplify
the code and keep the focus on basic concepts common to most languages. For example, PHP print statements
are used rather than echo statements, and these statements always include parentheses and double quotes so that
the syntax is more consistent with the output statements of most other languages. The last chapter (“Where to Go
From Here”) clarifies which practices are standard and which are particular to the textbook.

18
Intended Audience
The book is designed to serve:

Instructors teaching introductory programming, programming logic and design, or Web programming
courses, who want a textbook that engages students and provides a solid preparation for subsequent courses,
but avoids overwhelming beginners with too much syntactical detail or program complexity.
Traditional and online students taking a first course in programming, programming logic and design, or
Web programming.
Web designers, graphic artists, technical communicators, and others who find that their work increasingly
requires some degree of programming expertise, and need an effective, hands-on introduction.
Others who wish to learn the basics of programming, either for personal interest, or to explore the
possibility of a career in this field.

Note that solutions to quizzes and exercises are only available to verified course instructors.

19
Approach
The book takes a fairly novel approach, allowing students to learn program logic and design by developing a large
number of small Web-based applications. Students love working with the Web, and this approach has other
important benefits:

Important concepts such as client/server design, server-side processing, and interface-driven code modules
can be introduced in the form of working applications, and then applied in hands-on exercises.
Students not only learn the essential control structures and syntax of a programming language, but also learn
to use a markup language (and associated style sheets), and a database query language to access and query a
database. This makes sense in today's programming environment where these languages are routinely used
in combination to develop a networked application.
The material is relevant to students across a range of disciplines: Computer Science, Information Systems,
Technical Communications, Network Systems, Digital Media, Web Technologies, Mobile Applications,
Database Programming, and other technology-related fields.
The focus on hands-on problem-solving and fundamental structures prepare students for next-level,
language-specific courses such as PHP, Python, Java or C++, as well as Web design and database courses,
without replicating a great deal of material, while the syntax covered here is generally consistent with these
and other languages.

The book makes use of a programming language (PHP), a scripting language (HTML), a style sheet language
(CSS), and a database query language (MariaDB or MySQL), but does not attempt to provide a complete
overview of these languages. Instead, students learn sufficient syntax to convert requirements into working
applications using basic programming structures, arithmetic and logical expressions, user interfaces, functions,
data files, and SQL queries. The focus remains on basic concepts, logic and design, algorithm development, and
common programming procedures. The book provides context throughout, explaining why each topic is
important, and referring students to related career paths.
Although the book focuses on Web-based applications, there is NO requirement for a network-based
programming environment. The book uses a fully functional but standalone Apache Web server (the open source
xampp distribution provided by the Apache Friends group) that students can install on a USB drive or home
computer simply by unzipping a file. Students can begin programming in HTML, PHP and MariaDB or
MySQL in literally minutes.

20
Features
Each chapter begins with clearly stated learning outcomes. Each topic is introduced using examples of simple
program requirements that are first developed as algorithms and interfaces and then realized in working code.
Code statements and control structures are explained step by step.
Different programming topics are treated in separate chapters. Even topics that are commonly combined, such
as counting loops and event-controlled loops, have their own chapters so that students have the chance to develop
and apply their understanding of each separately.
Each chapter includes quizzes that have been carefully developed to test the student's understanding of the
chapter's learning outcomes. The questions have been tested extensively in the classroom.
Three different types of coding exercise are provided at the end of each chapter:

Fixit exercises provide small programs that include a single error of some kind. These exercises help students
improve their problem-solving ability, test their understanding of key concepts, and develop tracing and
debugging skills.
Modify exercises provide working programs that must be modified to perform a somewhat different or
additional function. These exercises help students determine how and where to add new code, and test their
ability to read and understand existing code.
Code completion exercises allow students to apply concepts and tools covered in the chapter by developing
new applications. These exercises test the student's ability to: understand requirements, develop algorithms,
and produce working code. The code completion exercises follow consistent themes that are developed
throughout the book, so that students can more readily appreciate the value of new functionalities that they
learn in each chapter.

Templates for each exercise contain partially completed code so students don't waste time typing (and debugging)
code that is not relevant to the problem at hand. The templates also help instructors to streamline the grading
process.
The textbook comes with a standalone Web server that can be installed on a fixed or portable drive simply by
unzipping a file (so students can bring the software with them to work on computers at any location).
The server installation includes textbook folders that contain all code samples and exercise templates. Students
can complete the exercises simply by opening, editing, and saving the appropriate files. Assignments can be turned
in simply by zipping and submitting the appropriate chapter folder.
The textbook appendices provide additional learning resources designed to: (a) help individual students with
particular needs or interests (for example file/folder management, additional references, and help debugging
code); and (b) deliver useful topics not included in the chapters (for example data representation, additional
control structures, and multi-dimensional arrays).

21
Textbook Web Site
The textbook Web site ensures that both students and instructors have access to the most current resources
associated with this textbook. The Web site includes: everything you need to install and use the Web server; slide
presentations; and hints and help for students working through each chapter. The Web site also provides support
for verified instructors, including additional exercises, test banks, slide presentations, quiz solutions, code
solutions, and other instructional resources. The Web site can be found at:
http://www.mikeokane.com/textbooks/WebTech/

22
Changes to the Fourth Edition
In addition to minor corrections and improvements, this fourth edition of the book includes: a new install of the
xampp Apache Web server distribution with installation instructions for Windows, Mac OS, and Linux; revised
file naming conventions that are more standard for current web development; a hopefully improved redesign of
Chapters 7 and 8; additional materials and improvements to Chapter 13 (functions); references to both MySQL
and MariaDB in Chapter 14 (the actual code and descriptions are identical); a new Chapter 15 that introduces
Object-Oriented Programming.

23
Chapter Overview
Chapter 1: Introducing Computer Programming. Students learn the relationship between machine language
and high-level languages, and review common tasks that computer programs typically perform. The work of a
programmer is described, and the software development cycle is explained. The chapter highlights and briefly
summarizes design approaches such as algorithm development, interface design, client/server design and object-
oriented programming. Different programming languages are identified, and the distinction is made between
interpreted and compiled languages, and between markup and programming languages. Standalone and network
applications are also contrasted.
Chapter 2: Client/Server Applications—Getting Started. This chapter prepares students for the hands-on
work they will perform in subsequent chapters. File types and local and Internet addressing schemes are explained.
Instructions are provided to install, run, and test the required software. Students are shown how to create, store,
and run a number of sample applications in order to become familiar with the process of using a text editor,
saving files, running the Web server, and viewing the results in a Web browser.
Chapter 3: Program Design—from Requirements to Algorithms. The general characteristics and
requirements of effective instructions are explored, using human and program examples. Students walk through
the process of reviewing simple requirements, creating input, processing, and output (IPO) charts, designing the
interface, and developing solution algorithms. The chapter introduces sequence, selection and control structures,
variables and assignment operations, and arithmetic and logical expressions.
Chapter 4: Basics of Markup—Creating a User Interface with HTML. This chapter explains the significance
of data rendering, and provides a brief overview and history of Hypertext Markup Language (HTML).
Commonly used HTML tags are explained, and the student is shown how to apply these to create and organize
simple Web pages. Cascading style sheets are introduced. Students are shown how to create HTML forms to
obtain user input as a first step in developing interactive Web applications. HTML Tables are used to perform
simple form layout.
Chapter 5: Creating a Working Program—Basics of PHP. This chapter teaches sufficient PHP language
syntax to process user input received from HTML forms, perform simple arithmetic, and produce formatted
output. In the process, students learn to code arithmetic expressions, use standard operators and functions, create
and work with variables, and identify and fix both syntax and logical errors.
Chapter 6: Persistence—Saving and Retrieving Data. This chapter explains the difference between persistent
and transient data, and introduces text file processing as well as basic database concepts. Students learn to: open,
read, write, and close text files; work with multiple files; parse lines of data that contain multiple values separated
by some kind of delimiter.
Chapter 7: Programs that Choose—Introducing Selection Structures. This chapter introduces selection
control structures and demonstrates the use of algorithms to solve problems requiring simple selection. Students
learn to use IF and IF..ELSE structures, Boolean expressions, relational operators, truth tables, simple string
comparisons, and testing procedures.
Chapter 8: Multiple Selection, Nesting, ANDs and ORs. This chapter develops examples from Chapter 7 to
handle problems associated with input validation and more complex requirements. Students explore the use of
compound Boolean expressions, nested selection structures, chained IF..ELSEIF..ELSE selection structures, and
multiple but independent selection structures.
Chapter 9: Programs that Count—Harnessing the Power of Repetition. This chapter introduces loop
structures with a focus on count-controlled FOR loops. Students learn how to refer to the counting variable
within the loop, and how to use loops to generate tables, crunch numbers, accumulate totals, find highest and
lowest values in a series, select values from a file of records, and display bar charts.
Chapter 10: “While NOT End-Of-File”—Introducing Event-Controlled Loops. This chapter introduces
WHILE loops and demonstrates the use of the priming read and the standard algorithm to process files of
unknown length. The student is shown how WHILE loops can be used to perform various operations on a list of

24
data values, and how a file of records can be processed and searched for specific records or field values.
Chapter 11: Structured Data—Working with Arrays. This chapter introduces numerically-indexed arrays,
and shows how arrays can be used to store, access, and update multiple-related values. The use of the FOR loop
to process arrays is explained, and various array-processing algorithms are demonstrated.
Chapter 12: Associative Arrays. This chapter introduces associative arrays. Students learn how to use
associative arrays as lookups, and gain a better understanding of the $_POST array and the way that data is
received from HTML forms. Web sessions are introduced, and students learn how to use the $_SESSION array
to maintain session data between applications.
Chapter 13: Program Modularity—Working with Functions. This chapter demonstrates the importance of
program modularity and introduces functions, include files and objects. Students learn to write their own
functions, to build libraries of related functions, and to call functions from different applications as needed.
Chapter 14: Connecting to a Database—Working with MySQL. This chapter introduces databases queries
as an important application tool. The relationship between relational databases and SQL is explained, along with
the purpose and syntax of common queries (SELECT, INSERT, UPDATE and DELETE). Students learn to
write code to open and close database connections, submit queries, handle errors, perform simple joins, and
process results.
Chapter 15: Introduction to Object-Oriented Programming. This chapter introduces Object-Oriented
Programming. Examples show how simple object classes are designed, how class variables are encapsulated and
accessed by class methods, how objects are instantiated and used in applications, and how classes can be inherited
by other classes. An overview of basic OO terminology is provided.
Chapter 16: Where to Go From Here. This last chapter provides a short overview of key concepts and
technologies that the students may want to explore after completing this textbook, along with clarification of
some of the conventions followed in the book.
The textbook also includes a number of useful appendices as follows:
Appendix A introduces data representation, and shows how binary values can store data for a wide range of
purposes.
Appendix B provides an introduction to overview of file and folder management, file addressing schemes
(including relative and absolute addresses), and the use of the command line with a list of common DOS and
Unix command equivalents.
Appendix C provides help for students wishing to use different Web server installations.
Appendix D provides debugging help for students having trouble identifying and resolving PHP code errors.
Appendix E provides additional material and references for students wishing to learn more about HTML and
style sheets.
Appendix F provides additional information regarding PHP data types, and provides a list of common PHP
functions not covered in the book.
Appendix G provides additional coverage of common PHP operators and structures that were omitted from
the chapters to avoid overwhelming the beginning student (for example, shortcut operators, the SWITCH
statement, DO..WHILE loops, and multi-dimensional arrays).

25
Acknowledgments

This textbook could not have been created without the generous help and support of many others. In particular I
want to thank my dear wife Constance Humphries for her invaluable technical advice, proof-reading,
development of video tutorials, and daily encouragement and patience! My sincere thanks to Scott Sipe, Beth
Hall, Sara Hjelt, and all at Carolina Academic Press for their supportive style, professionalism and experience.
Thanks to all my fellow instructors at A-B Tech (Asheville-Buncombe Technical Community College), especially
to Charlie Wallin and Fred Smartt who field-tested the first edition, and provided invaluable suggestions and
corrections. And thanks to all of those students who have learned with me and sometimes in spite of me as this
book evolved in the classroom. A particular thank you to A-B Tech students Uma Benson, Jean-Jacques Maury,
and Kenneth Stanley, who all voluntarily provided me with carefully compiled lists of corrections that were
incorporated into the fourth edition. Their engagement with the material and concern for future students is
greatly appreciated. Any remaining errors or inconsistencies are of course my own.
Lastly, a huge thank you to Kai ‘Oswald’ Seidler, Kay Vogelgesang, and all those who have contributed to the
Apache Friends Project, and who continue to deliver and support the XAMPP distribution. So many of us owe
you our great appreciation for your generosity of spirit!

26
About the Author

Mike O'Kane holds a master's degree in Systems Science (specializing in Advanced Technology) from
Binghamton University. He has over eighteen years' experience teaching computer science courses, most recently
at Asheville-Buncombe Technical Community College in North Carolina. He also has extensive practical
experience in the use of technology for learning, having worked at IBM as a short-course developer, NC State
University as an Instructional Coordinator, and the University of North Carolina system as the first Executive
Director of the UNC Teaching and Learning with Technology Collaborative. He has a passion for developing
effective instructional content, and learning environments that promote rather than hinder student learning.

27
Chapter 1

Introducing Computer Programming

Intended Learning Outcomes


After completing this chapter, you should be able to:

Explain the difference between computers and other machines.


escribe the purpose of the microprocessor's instruction set.
Explain the relationship between the instruction set and machine language.
List some common tasks that computer programs perform.
escribe what programmers do.
Summarize the stages of the software development cycle.
Explain the importance of writing and communications for programmers.
Explain the relationship between high-level programming languages and machine language.
istinguish between the purpose of a compiler and an interpreter.
Explain the difference between standalone and network applications.
Explain the difference between programming languages and markup languages.

28
Introduction
Welcome! If you have never programmed before, this book is for you. By the time you complete the chapters and
exercises, you will have a good grasp of the basic logic and design of computer programs. The book is designed to
teach common programming syntax and control structures in a manner that will prepare you for further study in
this field, and provide you with sufficient expertise to develop small, interactive Web applications, using a
combination of the HTML markup language and PHP programming language. You will also be introduced to
the CSS stylesheet language, and the MariaDB and MySQL database languages.
To get started, in this first chapter we will explore the general process of programming and define some
important term and practices. For a book that is supposed to be hands-on this chapter is mostly descriptive! Don't
be too concerned if some of the topics don't make complete sense yet. Your understanding will deepen as you
work through the chapters and develop your own applications.

29
Exploring the Variety of Random
Documents with Different Content
“You are the noblest man in the world!”
A quick spasm crossed his face in the darkness. Noble! Yet how little
popular esteem seemed to him at that moment! He went on
hurriedly, for what he had to say must be in few words:
“Always—whatever happens—you will remember what I have said,
Teresa?”
Whatever happens! She threw her arms about his neck, mute with
the anguish that was fighting with her resolution.
“—that you are all to me. That I love you—you only; that I shall love
you to the end.”
“If I forgot that, I could not live!” she said chokingly.
The great clock struck ponderously from the palace hall—a
clamorous reminder that he must hasten, for the night was almost
without a star, and a wreathing nebulous mist forbade rapid riding.
Through all his preparations this hour had reared as the last harbor-
light of home. It had come and gone like a breath on glass. In the still
night the chime sounded like a far spired bell. Some banal freak of
memory brought to Gordon’s mind the old church dial jutting over
Fleet Street in London, and the wooden wild men which had struck
the hour with their clubs as he issued from John Murray’s shop the
night of his maiden speech in Parliament.
The strokes counted twelve—midnight. She shuddered as he rose to
his feet.
“My love—my life!” he said, and clasped her close.
“God keep you!” she breathed.
He left her and went a few steps into the darkness. She thought him
gone. But he came back swiftly, his hands groping.
He heard a shuddering sob tear its way from her heart, but she stood
motionless in his arms, her cheek grown suddenly cold against his
own.
In that moment a strange feeling had come to her that they clasped
each other now for the last time. It was as though an icy hand were
pressed upon her heart, stilling its pulsations.
She felt his arms again release her and knew she was alone.

It lacked an hour of day when Gordon rode into Leghorn, and the
first streak of dawn strove vainly to shred the curdled mist as he
stepped from a lighter aboard the Hercules. The tide was at full and
a rising breeze flapped the canvas.
Standing apart on her deck, his mind abstracted, though his ears
were humming with the profane noises of creaking cordage,
windlass and capstan, he felt as if the fall of the headsman’s ax had
divided his soul in two. He saw his past rolled up like a useless
palimpsest in the giant hand of destiny—his future an unvexed scroll
laid waiting for mystic characters yet unformed and unimagined.
Beneath the bitterness of parting, be felt, strangely enough, a kind of
peace wider than he had ever known. The hatred that tracked, the
Nemesis that had harassed, he left behind him.
Absorbed in his reflections, he did not hear the bawled orders of the
ship’s mate, nor the spitting crackle of musketry from some ship’s
hulk near-by in the foggy smother. The brig was lifting and pushing
as she gained headway. The captain spoke at his elbow.
“Begging your lordship’s pardon, a man has just come aboard by the
ship’s bow-chains. He had a tough swim for it and a bullet through
the forearm. Says he was shanghaied by the Pylades. If we put
about, we’ll lose the tide. What are your lordship’s orders?”
“Is he Italian?”
“No, sir. He says he’s an Englishman, but he looks Lascar.”
“His name?” the demand fell sharply.
“Trevanion, your lordship.”
As Gordon stood there, breathing deeply, Teresa, at home in her
room, stretched at the foot of the crucifix, was crying in a voice of
anguish, that icy hand still pressed upon her heart: “O God! help me
to remember that it is for Greece! and for himself most of all! Help
me not to forget—not to forget!”
For only an instant Gordon hesitated. “Let him stay,” he said then to
the captain, and turned away to his cabin.
CHAPTER LVII
THE MAN IN THE RED UNIFORM

From a vessel lying beyond the shallows that stretched three miles
from the Greek shore, a puff of smoke broke balloon-like, to be
followed, a moment after, by a muffled report.
The crowds of people clustered along the town’s front cheered wildly.
Every day for weeks they had been watching: blue-eyed, dusky
Albanians, with horse-hair capotes and pistoled girdles; supple
lighter complexioned Greeks in the national kirtle; Suliotes, whose
mountain wildnesses were reflected in their dress; and a
miscellaneous mixture of citizens of every rank and age.
For this vessel bore the coming savior of the Grecian nation, the
great English peer whose songs for years had been sung in their
own Romaic tongue, whose coming had been prated of so long by
their primates—he who should make them victorious against the
Turk. Was it not he who, in Cephalonia, on his way hither, had fed
from his own purse the flying refugees from Scio and Patras, and
sent them back with arms in their hands? Was he not the friend of
their own Prince Mavrocordato, who in this same stronghold of
Missolonghi had fought off Omer Pasha with his twenty thousand
troops, and now controlled the provisional government of Western
Greece? Was it not he who had sent two hundred thousand piastres
to outfit the fleet before whose approach Yussuff Pasha’s squadron
had withdrawn sullenly to Lepanto?
They had known of Gordon’s departure from Cephalonia from the
forty Mariotes he sent ahead to be his own body-guard, and who
strutted it about the fortifications, boasting of the distinction. His
consort vessel had arrived, after narrowly escaping capture. His own
brig, chased by the Turks, had been driven on the rocky coast. This
they had learned from a surly Arab-like Englishman, his arm in a
sling from an unhealed bullet-wound, who had been in the vessel
and had found a footsore way overland.
The metropolitan had called a special service in the church for his
lordship’s deliverance. Now his ship, escaping rocks and the enemy,
had anchored safely in the night, and the roar of salutes from the
Speziot brigs-of-war that lay in the harbor had waked the sleeping
port. Since daylight the shore had been a moving mass, sprinkled
with brilliant figures: soldiery of fortune, wearing the uniform of well-
nigh every European nation.
There was one who watched that pushing, staring multitude who did
not rejoice. As he listened to the tumult of gladness, Trevanion’s
heart was a fiery furnace. His hatred, fostered so long, was the “be-
all and end-all” of his moody existence, and the benefit Gordon had
conferred when he delivered him from Cassidy’s marines, had
become at length insupportable. With a perversion of reasoning
characteristically Asiatic, he had chosen to wipe it from the slate and
make the favor naught. He went to Leghorn and to the amaze of
Cassidy, surrendered himself to the Pylades.
This voluntary act, perhaps, made vigilance lighter. He watched his
chance, leaped overboard in the foggy morning, and would have got
safe to shore but for one well-aimed musket. Chance put the
departing brig in his way. He had been delirious in the forecastle for
days from his wound, and knowledge of Gordon’s presence and
mission had not come to him till the Grecian shore was in sight.
In his durance on the Pylades his hair and beard had grown; he
fancied himself unrecognized. Hour by hour, watching Gordon
covertly, seeing him living and sleeping on deck in all weathers,
eating the coarse fare and enduring every privation of his sailors,
Trevanion’s blood inflamed itself still more. He owed the other
nothing now! He raged within himself at the celebrity the expedition
and its leader acquired at Cephalonia. In the pursuit of Gordon’s
vessel by the Turks he had hoped for its capture. When she ran
upon the rocks he deemed this certain, and forsook her jubilantly. He
had no fear of making his way afoot to Missolonghi; strangely
enough, years before, during the Feast of Ramazan, he had fled
over this same path to escape a Mohammedan vengeance, and
pursued by the memory of a Greek girl abandoned to the last
dreadful penalty because of him—a memory that haunted him still.
To-day, as Trevanion saw the vessel that held his enemy, his eyes
gleamed with a sinister regard.
“Bah!” sneered a voice behind him in the Romaic tongue. “An
English noble! Who says so? Mavrocordato. There are those who
say he is a Turk in disguise who will sell the country to the sultan.”
The man who had spoken wore the dress of a chieftain of lower
rank. His comrade answered with an oath:
“Or to the English. Kalon malubdi! Give me a chief like Ulysses! In
six months he would have gained the whole Peloponnesus, but for
the coming of this foreigner—may a good ball find him!”
To Trevanion the malediction was as grateful as a draft of cool beer
to the scorched palate of a waking sot. He spoke in the vernacular:
“There are English, too, who would drink that toast! Who is
Ulysses?”
His faded sailor’s rig had been misleading. Both clapped hands to
their belts as, “One who will sweep this puppet of Mavrocordato’s
into the gulf!” the first replied fiercely.
“May I be there to help!” exclaimed Trevanion, savagely. “Take me to
this leader of yours!”
The two Suliotes looked at him narrowly, then conferred. At length
the chief came closer.
“If you would serve Ulysses,” he said, “meet me beyond the north
fortifications at sunset.”
Trevanion nodded, and they turned away, as a shout went up from
the assembled people. A boat had swung out from the brig’s davits.
It carried a flag—a white cross on a blue ground—the standard of
New Greece.
The man with the disabled arm flushed suddenly, for his dark, sullen
gaze had fallen on the sea-wall, where stood His Highness, Prince
Mavrocordato, with Pietro Gamba. The latter had followed Gordon to
Cephalonia and from there had come on the Hercules’ consort. A
slinking shame bit Trevanion as he recalled the day when his
poisoned whisper would have fired that young heart to murder; he
wheeled and plunged into the human surge.
The couple on the sea-wall watched eagerly. The lowered boat had
been rapidly manned. A figure wearing a scarlet uniform took its
place in the stern-sheets. The crowd buzzed and dilated.
The prince lowered his field-glass. “Thank God, he is safe!” he
exclaimed in earnest Italian. “We have been in desperate straits,
Pietro. With the General Assembly preparing to meet, when all the
western country is in such disorder, with these untamed mountain
chiefs flocking here with their clans, with Botzaris killed in battle, and
only my paltry five thousand to keep dissensions in check, I have
been prepared for the worst. Now there is hope. Look!”
He stretched his hand toward the teeming quay. “They have waited
for him as for the Messiah. All the chiefs, except Ulysses, who has
always plotted for control—and his spies are in the town at this
moment!—will defer to him. With a united front what could Greece
not do! The Turk could never enslave her again. With no supreme
head, her provinces are like the untied bundle of sticks—easily
broken one at a time!”
They watched in silence while the rowers drew nearer across the
shallows.
“I did not hope to see you here, Pietro,” Mavrocordato said
affectionately, as they started toward headquarters.
Gamba answered simply: “She sent me—to guard him if I could.”
Ten minutes more and the boat was at the landing.
The instant its bow touched the masonry before line of picked troops,
a single bell rang out from the Greek church. Other iron tongues took
it up. The walls shook with rolling salvos of artillery, the firing of
muskets and wild music, as the man in the scarlet uniform, colorless
and strangely composed amid the tossing agitation, stepped on
shore to grasp the hand of Prince Mavrocordato, standing with a
long suite of European and Greek officers.
As his gaze swept over the massed soldiery, the frantic people, the
women on roofs and balconies, the houses hung with waving
carpets,—a rainbow motley of color,—a great shout rolled along the
embankments, a tumult mingled with hand-clapping like a silver rain,
that drowned all words. Women in the multitude sobbed, and on the
balconies little children were held up in stronger arms to see their
deliverer. Every eye was on that central figure, with face like the
Apollo Belvedere and a step that halted as if with fatigue, but with a
look clear and luminous and the shadow of a smile moulding his lips.
“Panayeia keep him!” sobbed a weeping woman, and threw herself
between the lines of soldiers to kiss the tassel of his sword.
The metropolitan, his robes trailing the ground, lifted before him a
silver eikon glittering in the sun.
The soldiers presented arms.
The bells broke forth again, and amid their jubilant ringing the wearer
of the red uniform passed slowly, with Prince Mavrocordato by his
side, into the stone building which rose above the quay—the military
headquarters of the revolutionary forces of Western Greece.
CHAPTER LVIII
THE ARCHISTRATEGOS

Missolonghi had become the center of European attention. The


announcement of the English Committee which followed Blaquiere’s
return to England was on every tongue.
The Courier had printed a single sneering paragraph in which had
been compressed the rancor of William Godwin, the bookseller. This
stated that George Gordon was not even in Greece, that he was in
reality living in a sumptuous villa on one of the Ionian Islands, with
the Contessa Guiccioli, writing a companion poem to “Don Juan.”
But before the stringent disapproval with which this bald fabrication
was received, the Courier slunk to shamefaced silence.
Thereafter, in the columns of newspaper, pamphlet and magazine,
there was to be distinguished a curious tension of reserve. It was the
journalistic obeisance to a growing subterranean yet potent revulsion
of feeling. Dallas had soon found himself the recipient of invitations
from influential hosts desirous to hear of his visit to Italy. In the clubs
the committee’s bulletins were eagerly discussed. The loan it
solicited found subscriptions and the struggle of the Cross with the
Crescent—the cause whose beating heart was now Missolonghi—
began to draw the eyes not of London but of England; not of England
but of Europe; not of Europe but of the world.
To the company gathered in the citadel of this little marshy port on
the Greek sea-shallows, where freedom stirred in the womb of war,
outer comment came only after multiplied reverberations. They toiled
ceaselessly—a nucleus of hard-working general officers culled from
everywhere—planning, drilling, gathering stores, preparing for the
inevitable attack of the Turkish armies massing at Lepanto, trying to
knit into organization the tawdry elements of brigandage to which
centuries of Turkish subjection had reduced a great nation. They
labored under a single far-sighted leadership: that of the
archistrategos of the Greek forces, whose eye seemed sleepless
and his brain indefatigable.
Gordon foresaw that Greece’s greatest enemy was not the Turks,
but her own dissensions. Unification of spirit and authority was
necessary before all. When Ulysses, the recalcitrant, sent him an
obsequious embassy it bore back a terse answer: “I come to aid a
nation, not a faction.” Ulysses cursed in his beard and sent
Trevanion, for whom he had found more than one cunning use, to
seduce the Suliote forces camped within the insurgent lines.
Meanwhile, the money Gordon had brought melted rapidly. He had
contributed four hundred pounds a week for rations alone, besides
supporting batteries, laboratories and an entire brigade, settling
arrears and paying for fortification. However large his private
resources, they must soon be exhausted. Could the English loan
fail? And if not, would it come in time? If it was too long delayed,
disaster must follow. Discipline would lapse. The diverse elements
on the point of coalescing, would fly asunder. The issue would be
lost. This thought was a live coal to him night and day.
The rainy season set in with all its rigors. Missolonghi became a
pestilential mud-basket beside which the dikes of Holland were a
desert of Arabia for dryness. An unknown plague fastened on the
bazaar and terrified the townspeople. But in all conditions, Gordon
seemed inspirited with a calm cheerfulness.
He thought of Teresa continually. Oddly enough, she stood before
him always as he had once seen her on a square in Venice, with
moonlight tangling an aureole in her gold hair, her face now not
frozen with mute horror—that picture had vanished forever!—but
serene with love and abnegation. This face lighted the page as he
labored with his correspondence. It went with him on the drenching
beach when he directed the landing of cannon sent by the German
committee—more dimly seen this day, for a peculiar dizziness and
lethargy which he had battled for a fortnight, was upon him.
As he rode back through the rain and the bottomless quagmire,
Prince Mavrocordato and Pietro Gamba sat waiting in his room at
headquarters. They had been talking earnestly. The outlook was
leaden. There had been as yet no news of the expected loan. The
lustful eyes of foreign ministers were watching. Ulysses had seized
the acropolis of Athens, and his agents were everywhere, seeking to
undermine the provisional government. The Suliotes, whose chiefs
swarmed in Missolonghi, had begun to demand money and
preferment.
But these things, serious as they were, weighed less heavily upon
Prince Mavrocordato’s mind than the health of the man he now
awaited in that cheerless chamber.
“Another post would do as well,” the Greek said gloomily. “Higher
ground, out of the marshes. He stays here only at risk to himself. Yet
he will listen to no proposal of removal.”
“What does he say?” asked Gamba.
“That Missolonghi is the center of Western Greece, the focus-point of
European observation. And he ends all discussion by the question:
‘If I abandoned this castle to the Turks, what would the partizans of
Ulysses say?’”
Gamba was silent. Mavrocordato knit his bushy brows. He knew the
answer only too well. And yet the safety of this single individual had
come to mean everything. Without him Greece’s organization would
be chaos, its armies, rabbles.
While he pondered, Gordon entered. He had thrown off his wet
clothing below. The shepherd-dog crouched by the door, sprang up
with a joyful whine as the new-comer dropped a hand on his head.
Pietro had a sudden vision of his sister as she placed upon him her
last injunction—to guard this man’s life. He had done all he could.
Yet to what avail? Watchfulness might ward steel and lead, but what
could combat the unflagging toil, the hourly exposure, the stern
denial of creature comfort? His eyes wandered around the damp
walls hung with swords, carbines and pistols, to the rough mattress
at one side, the spare meal laid waiting the occupant’s hasty leisure.
In his mind ran the words with which Gordon had replied to one of
his protests: “Here is a stake worth millions such as I am. While I can
stand at all, I must stand here.” Gamba’s thought returned to what
the prince was saying:
“Allow me at least to furnish this chamber for your lordship. A bed—”
“Our Suliotes spread their mats on the ground,” was the reply, “or on
the dirt floor of their miserable huts. I am better couched than they.”
“They are used to it,” protested the Greek. “They have never known
better. They are proof against marsh fever, too.” He paused an
instant, then added: “I have just learned that the wines I have
ordered sent you, have on each occasion been returned to the
commissariat.”
Gordon’s gaze had followed the other’s. The food spread there was
of the meanest: goat’s meat, coarse peasant’s bread, a pitcher of
sour cider. He was fighting back a vertigo that had been misting his
eyes.
“My table costs me exactly forty-five paras. That is the allowance of
each Greek soldier. I shall live as they live, Prince, no worse, no
better.”
His voice broke off. He reeled. Mavrocordato sprang and threw an
arm about him. Pietro hastened to send Fletcher to the improvised
hospital for the physicians.
They came hastily, to find Gordon in a convulsion of fearful strength,
though it lasted but a moment. Leeches were put to his temples and
consciousness returned. He opened his eyes upon an anxious group
of surgeons and staff-officers.
A commotion arose at the instant from the courtyard. Mavrocordato
stepped to the window. He made an exclamation. The place was
filling with Suliotes—they were dragging its two cannon from their
stations and turning their muzzles against the doors.
An orderly burst into the room. “They are seizing the arsenal!” he
cried.
With an oath a Swedish officer leaped down the stair, drawing his
sword as he ran. He fell stunned by the blow of a musket-butt.
Wild figures, their faces and splendid attire splashed with mud,
gushed in, choked the stairway, and poured into the narrow
apartment—to waver and halt abruptly, abashed.
This was not what Trevanion had craftily told them of—not the abode
of soft luxury and gem-hung magnificence affected by the foreign
archistrategos whose wealth was limitless and who sipped wines of
liquid pearls, while they, their payments in arrears, drank sharp
raisin-juice. What they saw was at strange variance with this picture.
A chill stone chamber, a meager repast, uncarpeted floors. A handful
of men, each with a drawn sword. These—and a form stretched on a
rough mattress, an ensanguined bandage about his forehead, a
single gray-haired servant kneeling by his side.
The man on the couch rose totteringly, his hand on his servant’s
shoulder. He was ghastly white, but his eye flashed and burned as it
turned on those semi-barbaric invaders.
Gordon began to speak—not in the broader Romaic, but in their own
mountain patois, a tongue he had not recalled since long years. The
uncouth vocabulary, learned in his youthful adventurous journey for
very lack of mental pabulum, had lain in some brain-corner to spring
up now with the spontaneity of inspiration. At the first words they
started, looked from one to another, their hands dropped from their
weapons. His voice proceeded, gathering steel, holding them like
bayonets.
“Am I then to abandon your land to its enemies, because of you,
heads of clans, warriors born with arms in your hands, because you
yourselves bring all effort to naught? For what do you look? Is it
gold? The money I brought has purchased cannon and ammunition.
It has furnished a fleet. It has cared for your sick and set rations
before your men. Do you demand preferment? You are already
chiefs, by birth and by election. Have I taken that away? Rank shall
be yours—but do you hope to earn it idly in camp, or fighting as your
fathers fought, like your own Botzaris, who fell for his country? Is it
for yourselves you ask these things now, or is it for Greece?”
Of the staff-officers there gathered none knew the tongue in which
he spoke. But they could guess what he was saying. They saw the
rude chieftains cower before his challenge. Then, as he went on,
under that magnetic gaze they saw the savage brows lighten, the
fierce eyes soften and fall.
Gordon’s tone had lost its lash. His words dropped gently. He was
speaking of those old days when he had slept beneath a Suliote tent
and written songs of the freedom for which they now strove. The
handful beside him had put up their swords. For a moment not only
individual lives, but the fate of Greece itself had hung in the balance.
They watched with curious intentness.
As the speaker paused, a burly chieftain, built like a tower, thrust up
his hand and turned to the rest, speaking rapidly and with many
gesticulations. He pointed to the rough couch, to the coarse fare on
the table. The others answered with guttural ejaculations.
All at once he bared his breast, slashed it with his dagger, and
touched knee to ground before Gordon’s feet. The rest followed his
example. Each as he rose, saluted and passed out. Before a dozen
had knelt, the rumble of wheels in the courtyard announced that the
cannon were being dragged back to their places.
The last Suliote chief retired and Gordon’s hand fell from Fletcher’s
shoulder. The headquarters’ surgeon broke the tension:
“His lordship must have quiet!” he warned.
The whiteness had been growing upon Gordon’s face. As the officers
retired, he sank back upon the couch. Mavrocordato held brandy to
his lips, but he shook his head.
He lay very still for a while, his eyes closed, hearing the murmuring
voices of the prince and Gamba as they stood with the physicians,
feeling on the mattress a shaking hand that he knew was Fletcher’s.
A harrowing fear was upon him. The mutiny that had been imminent
this hour he had vanquished; he might not succeed again. With
resources all might be possible, but his own funds were stretched to
the last para. And the English loan still hung fire. If he but had the
proceeds of a single property—of Rochdale, which he had turned
over to the committee in London—he could await the aid which must
eventually come. Lacking both, he faced inaction, failure; and now to
cap all, illness threatened him. He almost groaned aloud. Greece
must not fail!
There was but one way—to fight and fight soon. Instead of waiting till
famine made ally with the enemy, to attack first. To throw his forces,
though undisciplined, upon the Turks. Victory would inspirit the
friends of the revolution. It would knit closer every segment. It would
hasten the loan in England. Might the assault be repelled? No worse,
even so, than a defeat without a blow—the shame of a cowardly
disintegration!
“Prince—” Gordon summoned all his strength and sat up. “May I ask
you to notify my staff-officers to meet me here in an hour? We shall
discuss a plan of immediate attack upon Lepanto.”
CHAPTER LIX
IN WHICH TERESA MAKES A JOURNEY

“Help me to remember that it is for Greece—and for himself most of


all!” That was Teresa’s cry through those dreary weeks alone. The
chill instinct that had seized her as Gordon held her in that last clasp
had never left her. She struggled always with a grim sense of the
inevitable. At times she fought the desire to follow, even to Greece,
to fold him in her arms, to entreat: “Give up the cause! Come back to
me—to love!” Her sending of Pietro had given her comfort. She
subsisted upon his frequent letters, upon the rarer, dearer ones of
Gordon, and upon the remembrance of the great issue to which she
had resigned him.
One day a message came from a great Venetian banking-house. It
told of a sum of money held for her whose size startled her. She,
who had possessed but a slender marriage-portion, was more than
rich in her own right. An accompanying letter from Dallas told her the
gift was Gordon’s. A wild rush of tears blurred the page as she read.
That night she dreamed a strange dream; yet it was not a dream
wholly, for she lay with open eyes staring at the crucifix that hung
starkly, a murky outline, against the wall. Suddenly she started up in
the bed. Where the ivory image had glimmered against the ebony
was another face, colorless, sharp-etched, a wavering light playing
upon it. It was Gordon’s, deep-lined, haggard, as though in mute
extremity. His eyes looked at her steadily, appealingly.
She held out her arms with a moan. Then the light faded, the
phantom merged again into the shadow, and in the darkness she hid
her eyes and swayed and wept. She slept no more. A blind terror
held her till dawn.
At noon Tita brought her a Pisan paper, with a column of Greek
news. It stated that the English loan, on which depended the hopes
of the revolutionists, was still unsubscribed in London. The measure
would doubtless be too late to stay the descent of Yussuff Pasha’s
armies. Dissensions were rife at Missolonghi. At Constantinople the
sultan, in full divan, had proclaimed George Gordon an enemy to the
Porte and offered a pashawlik and the three-horse-tailed lance for
his head.
The English loan—too late! Its speedy coming had been a certainty
in Gordon’s mind before his departure. Was it the agony of failure
she had seen on the face that looked at her from the darkness? Was
he even now crucified on the cross of a despairing crisis?
A quick thought came to her. The sum he had made hers—a fortune,
almost a hundred thousand pounds of English money! Might not that
serve, at least until the loan came? If she could help him thus!
There was no time for correspondence, banking routine—no time for
delays of any sort. It must go now! A daring plan was born in her
mind. She could take it herself, direct to his necessity. Why not?
Such a brig as Gordon had chartered was no doubt to be found at
Leghorn. Yet she could not make the voyage with but a single
servant for escort. To whom could she appeal? To whom else could
that far-away cause be near?
A figure flashed before her with the directness of a vision—a man
she had seen but once, when with her husband, he had confronted
her on a monastery path one dreadful buried day. The friar of San
Lazzarro! She recalled the clear deep eyes, the venerable head, the
uncompromising honesty of the padre’s countenance. He had known
the man she loved—had seen his life in that retreat. Was he still
there? Would he aid her?
An hour more and she was riding with Tita toward Leghorn harbor.
By the next sunrise she was on her way to Venice. Three days later
Tita’s oar swung her gondola to the wharf of the island of Saint
Lazarus.
She stepped ashore and rang a bell at the wall-door beside which, in
its stone shrine, stood the leaden image of the Virgin, looking out
across the gray lagoon.
The place was very still. Peach-blooms hung their glistening spray
above the orchard close, and swallows circled about a peaceful spire
from which a slow mellow note was striking. It seemed to Teresa that
only yesterday she had stood there face to face with Gordon. With a
sudden impulse she sank to her knees before the shrine.
When she rose she was not alone; he who she had prayed might still
be within those walls stood near—the same reverend aspect, the
benignant brow, the coarse brown robe.
“What do you seek, my daughter?”
As Teresa told her errand, looking into the soluble eyes bent on her,
the breeze stirred the young leaves, and the tiny waves lapped the
margin-stones in a golden undercurrent of sound. Her words,
unstudied and tense with feeling, acquired an unconscious
eloquence. A great issue in perilous straits; she, with empty
affluence that might save it—but alone, without companion for such
a journey.
The friar listened with a growing wonder. In the seclusion of that
solitude he had long since heard of the Greek rebellion—had
yearned for its success. But it had been a thing remote from his
lagoon island. He? To leave the peace of his studies to accompany a
woman, to a land in the throes of war? A strange request! Why had
she come to him?
“Have I ever seen you before, my daughter?”
Her heart beat heavily. “Yes, Father.”
She was leaning against the rock, her face lifted to his. The posture,
the pathetic purity of her features, brought recollection.
Padre Somalian’s eyes lighted. Since that unforgotten scene on the
path, he had often wondered what would be this woman’s wedded
life, so tragically begun. By her face, she had suffered. Her husband
had been old then—doubtless was dead. It was a mark of grace that
she came now to him—a holy man—before others. If, alone in the
world, she chose to consecrate her wealth thus nobly, well and good.
If there had been fault back of that rich marriage, such an act would
be in the line of fitting penance.
If there had been fault! The friar’s eyes turned away. He was thinking
of the stranger whose brow her husband’s blow had marked—of the
paper he himself had lifted from beneath the stone. Since the gusty
day when he found the abandoned robe, he had prayed unceasingly
for that unknown man’s soul.
“You will go?”
The question recalled his thought, gone afar.
“My daughter,” he demurred, “who am I, bred to quiet and
contemplation, to guide you in such an enterprise?”
Tears had come to Teresa’s eyes. “Then the hope of Greece will
perish! And he—its leader, who has given his all—will fail!”
The padre’s look clouded. It was the undying war of Christendom
against the idolater, the fight the church militant must wage daily till
the reign of the thousand golden years began. Yet noble as was the
Grecian struggle, to his mind it had been smirched by a name famed
for its evil.
“I would so fair a cause had a better champion!” he said slowly.
Her tears dried away. “And you say that?” she cried, her tone
vibrating. “You who saw him, and with whom he lived here?—you?”
He thought her distrait. “He here? What do you mean?”
“Do you not know? Father, he who leads the Greeks is the man with
whom I stood that day beside this shrine!”
The friar started. Rapid emotions crossed his face. For many a
month a sore question had turned itself over and over in his mind.
Had he stumbled in his duty to that man who had come in
hopelessness and departed with despair unlightened? Day after day
he had seen the misery reflected in the countenance. He knew now
that he had been witnessing the efforts of a fallen soul to regain its
lost estate—a soul that was now fighting in the ranks of the Cross! In
his own self-reproach he had prayed that it might be given him again
to hold before his eyes the symbol of the eternal suffering. Was this
not the answer to that prayer?
His eyes suffused.
“Wait for me here, my daughter,” he said. “I shall not be long. We go
together. Who knows if the summons you bring be not the voice of
God!”
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