PHP Programming with MySQL, Second Edition
Don Gosselin, Diana Kokoska, Robert Easterbrooks

Errata Page

Chapter 1
Page 54
Chapter Exercise 1-20 (ComparisonExample.php), Step 4 – The last echo statement should read:
echo '$Value1 not equal to $Value2 OR not the same
data type: ', 
$ReturnValue, "</p>";

Figure 1-32 (bottom of page) – The last line should read:
$Value1 not equal to $Value2 OR not the same data type: false

Page 70
Reinforcement Exercise 1-3, Step 4 – Replace both occurrences of the variable name $SingleFamilyHome_Print with the variable name $SingleFamilyHome_Display in the instructions for the step.

Chapter 2
Page 108
Chapter Exercise 2-9 (DiceRoll.php), Step 7 – The instructions should be modified to read as follows:
Modify the echo statement to display the $RollCount variable instead of the $RollNumber variable. Modify the call to the CheckForDoubles() function to use $Die1 and $Die2 instead of $Die[0] and $Die[1].
echo "The total score for roll $RollCount was 
     $Score.<br />";
$Doubles = CheckForDoubles($Die1,$Die2);

Page 115
Comprehension Check, Question #15 – Replace all four occurrences of the variable name $echo with the keyword echo (once in each of the four possible answers).

PowerPoint Slides 38 and 39 have been updated.

Chapter 3
Page 170
Chapter Exercise 3-13 (PHPEmail.php), Step 2 – There are two opening square brackets before the capital A, when there should only be one, as follows:
If (preg_match("/^[\w-]+(\.[\w-+)*@" .
                      "[\w-]+(\.[\w-]+)*(\.[A-Za-z]{2,})$/i",
         $Address)==1)

Page 181
Discovery Projects 3-1, Paragraph 1 – replace the file name home_links_bar.inc with the file name Includes/inc_home_links_bar.php.

Discovery Projects 3-2, Paragraph 1 – replace the file name home_links_bar.inc with the file name Includes/inc_home_links_bar.php.

Chapter 4
Page 193
Chapter Exercise 4-1 (Scholarship.html), Step 2 – A closing </p> tag should be appended to the next-to-last line, as follows:
<p><input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="Submit" value=
"Send Form" /></p>

Page 199
First Careful - The word ‘FALSE’ should be ‘TRUE’, as follows:
The empty() function returns a value of TRUE for a numeric value of 0. If you are validating a numeric field for which 0 is a valid entry, you must check for a value of 0 separately.

Page 202
Chapter Exercise 4-4 (process_Scholarship.php), Step 2 – The final n in the echo statement should be a newline escape sequence \n, as follows:
echo "The field \"$fieldName\" is required.<br />\n";

Page 204-5
Chapter Exercise 4-5, Step 2 – A closing </p> tag should be appended to the next-to-last line of XHTML code, as follows:
<p><input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="Submit" value="Send 
Form" /></p>

Page 225
Reinforcement Exercise 4-2 (ContactForm.php), Step 4 – The pattern string assigned to the $pattern variable has an extra set of square brackets for the [a-z] character set ([[a-z]]). The extra set of square brackets should be removed, as follows:
$pattern = "/^[\w-]+(\.[\w-]+)*@" .
     "[\w-]+(\.[\w-]+)*" .
     "(\.[a-z]{2,})$/i";

Page 229
Discovery Project 4-1 – Within the parentheses, the filename should be inc_home.php, not inc_home_page.php, as follows:
(The inc_home.php file has already been created.)

Chapter 5
Page 255
Chapter Exercise 5-5 (ViewFiles.php), Step 7 – Remove the trailing \n at the end of the last line, as follows:
echo "<a href=\"$FullEntryName\">" .
     htmlentities($Entry) . "</a>";

Page 263
Chapter Exercise 5-7 (VisitorFeedback.php), Step 5 – The instructions should read “code immediately after”, not “form immediately before”, as follows:
Add the following XHTML code immediately after the closing PHP tag:

Chapter 6
Page 314
“Removing Duplicate Elements”, Paragraph 1, Sentence 6 should be modified to read “Instead, it returns a new array with the duplicate values removed.” The words “duplicate values removed” should replace the words “renumbered indexes”.
Pages 326-7
	Chapter Exercise 6-9 (MessageBoard.php) – As written, the code will produce output with the subject line one message ahead of the remainder of the message data. To fix this problem, the following changes are needed.

	The instructions for Step 3 need the following text appended: The variable $Key is also declared and initialized. The $Key variable will contain the key of the current array element.

	The code for Step 3 should be as follows (note the new second line):
	$Index = 1;
	$Key = key($KeyMessageArray);

	The third echo statement in Step 4 needs to be modified as follows:
	     echo "<td width=\"85%\”><span
	          style=\"font-weight:bold\">
	          Subject:</span> " .
	          htmlentities($Key) .
	          "<br />";

	Another statement needs to be added immediately after incrementing $Index at the end of Step 4, as follows (top of Page 327):
	     echo "</tr>\n";
	     ++$Index;
	     $Key = key($KeyMessageArray);
	     next($KeyMessageArray);
	}
	 
Page 353
	Chapter Exercise 6-14 (MessageBoard.php), Step 3 – This step needs to be modified as follows to accommodate the changes to Pages 326-7:
	Delete the following two statements:
	$Index = 1;
	$Key = key($KeyMessageArray);

Page 357
	Second example – The symbol before each of the five inner array() declarations should be an array operator (=>), not an equal sign, as follows:
	$VolumeConversions = array(
          "ounces" => array("ounces" => 1,
               "cups" => 0.125, "pints" => 0.0612,
               "quarts" => 0.03125, "gallons" => 
               0.0078125),
          "cups" => array("ounces" => 8, "cups" => 1,
               "pints" => 0.5, "quarts" => 0.25,
               "gallons" => 0.0625),
          "pints" => array("ounces" => 16, "cups" => 2,
               "pints" => 1, "quarts" => 0.5,
               "gallons" => 0.125),
          "quarts" => array("ounces" => 32, "cups" =>
               4, "pints" => 2, "quarts" => 1,
               "gallons" => 0.25),
          "gallons" => array("ounces" => 128,
               "cups" => 16, "pints" => 8, "quarts" =>
               4, "gallons" => 1)
     );

Page 374
	Reinforcement Exercise 6-3 (EuropeanTravel.php), Step 4 – The instructions should be modified to read as follows:
4. Add the following code to the script section to declare an associative array of European cities and the distances between them in kilometers, the start and end city index variables, and the conversion factor for kilometers to miles:

	The following code needs to be added immediately before the line $KMtoMiles = 0.62; to initialize the start and end city index variables:
	$StartIndex = "";
	$EndIndex = "";

Chapter 7
Page 437
Comprehension Check, Question 11, Answer C should have a backtick character (`) in the parenthesis instead of a single quote.

Chapter 8
Pages 466-469
Chapter Exercise 8-5 (NewsletterSubscribe.php) -  The following two changes need to be made:
        Step 4 should be changed to read "Add the following initializations and if statement ...", while the code should be modified to read:
                $ShowForm = FALSE;
                $SubscriberName = "";
                $SubscriberEmail = "";
                if (isset($_POST['Submit'](( {
                }
                else {
                     $ShowForm = TRUE;
                }
        Step 11 should be modified to echo $SubscriberName instead of $SubName, and $SubscriberEmail instead of $SubEmail.

Chapter 9
Pages 502-505
Chapter Exercise 9-1, part 3 (RegisterIntern.php) - The following three changes need to be made:
        Page 503, Step 5 - The following line needs to be added to the beginning of the code block:
      $DBConnect = FALSE;
        
        Page 504, Step 5 (continued) - The call to the mysql_errno($DBConnect) function needs to be on a single line.
        
       Page 504, Step 6 – The third and fourth line of code should be modified as follows to change the value of $SQLString (note the space after $TableName and the single quotes around $email):
      $SQLString = "SELECT count(*) FROM $TableName " .
           "where email='$email'";
Page 507
Chapter Exercise 9-2, Part 1 (VerifyLogin.php), Step 3 - The call to the mysql_errno($DBConnect) function in the else clause needs to be on a single line.

Page 510
Chapter Exercise 9-2, Part 3 (AvailableOpportunities.php), Step 4 - The call to the mysql_errno($DBConnect) function in the else clause needs to be on a single line.
Chapter Exercise 9-2, Part 3 (AvailableOpportunities.php), Step 5 - The call to the mysql_errno($DBConnect) function in the inner if clause needs to be on a single line.

Pages 543-544
Reinforcement Exercise 9-1 (CancelSelection.php), Step 5 – The calls to the mysql_errno($DBConnect) function in the inner if clause and the inner if clause of the inner else clause need to be on a single line (two separate places).

Reinforcement Exercise 9-1 (CancelSelection.php), Step 6 – The call to the mysql_errno($DBConnect) function in the inner if clause needs to be on a single line. Also, line 29 ends the string being assigned to the $Body variable with a \p. This should be a \n.

End of list