Learning PHP, MySQL & JavaScript

Errata for Learning PHP, MySQL & JavaScript

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 722
Answers 2 and 3 (Chapter 12)

Answers 2 and 3 (page 722) use the term "set_cookie". Chapter 12 (pages 289-290) uses the term "setcookie". I couldn't find "set_cookie" in the PHP manual.

Note from the Author or Editor:
Answers 2 & 3 on P722 should replace set_cookie with setcookie

Jeff  Nov 19, 2019 
Printed
Page 305
Last paragraph, first sentence.

Last paragraph, first sentence reads as follows: Press Reload a few times here, and you should see it count up again from 0. Perhaps I'm not understanding the navigation instructions correctly, but the counter never seems to return to zero. It keeps on ever incrementing by one with each Reload.

Note from the Author or Editor:
The first sentence of the final paragraph on P305 should read Press Reload a few times here, and you should see it continue counting upwards.

Jeff  Nov 19, 2019 
Printed
Page 304
First sentence under heading "Preventing session hijacking

Sentence states the following: When SSL is not a possibility.... This was correct in Ed. 4 of this book. In Ed. 5, the concept of TLS (the successor to SSL) is being discussed. Therefore to be more consistent, the sentence should read as follows: When TLS is not a possibility...

Note from the Author or Editor:
The first sentence of the third paragraph of P304 should read When TLS is not a possibility...

Jeff  Nov 19, 2019 
Printed
Page 303
Example 12-8

The first if statement in Example 12-8 is the following: if (isset($_SESSION['username'])) However $_SESSION['username'] was never previously set. It was $_SESSION['forename'] that was set. The first if statement in Example 12-6 correctly uses $_SESSION['forename'], which I believe should be used in Example 12-8 (which itself is a tweak of Example 12-6). Also, Example 12-8 uses an echo statement combined with the htmlspecialchars function, which results in the program literally outputting .<br> on the screen.

Note from the Author or Editor:
Example 12-8 should be replaced with this: <?php session_start(); if (isset($_SESSION['forename'])) { $forename = $_SESSION['forename']; $surname = $_SESSION['surname']; destroy_session_and_data(); echo htmlspecialchars("Welcome back $forename"); echo "<br>"; echo htmlspecialchars("Your full name is $forename $surname."); } else echo "Please <a href='authenticate.php'>click here</a> to log in."; function destroy_session_and_data() { $_SESSION = array(); setcookie(session_name(), '', time() - 2592000, '/'); session_destroy(); } ?>

Jeff  Nov 18, 2019 
Printed
Page 301
Ex12-6

The second to last line of code in continue.php is the following: else echo "Please <a href=authenticate2.php>Click Here</a> to log in."; Unlike other <a> tags in the book, the href here (authenticate2.php) is not in single quotes.

Note from the Author or Editor:
Although not an error, for consistency the final line of code on P301 (prior to the closing ?> ) should be else echo "Please <a href='authenticate2.php'>Click Here</a> to log in.";

Jeff  Nov 17, 2019 
Printed
Page 269
Example 11-2

The following code: if (isset($_POST['name'])) $name = $_POST['name']; else $name = "(Not Entered)"; will only produce the text (Not Entered) upon running the first time. Any subsequent entry of nothing in the text box (i.e., leaving the field blank and clicking Submit) will not produce the text (Not Entered). The following code remedies this: if (!empty(($_POST['name']))) $name = $_POST['name']; else $name = "(Not Entered)";

Note from the Author or Editor:
The first two lines of Example 11-2 on P269 should be... if (!empty(($_POST['name']))) $name = $_POST['name']; else $name = "(Not Entered)";

Jeff  Nov 06, 2019 
Printed
Page 46
Table 3-3

Last three rows of Table 3-3, in the Description column, repeat the word "to": <> Is not equal to to === Is identical to to !== Is not identical to to

Note from the Author or Editor:
In Table 3-3 on P46 the final three rows have an extraneous word 'to' in non italics added at the end of the middle column text, which should be removed.

Jeff  Oct 11, 2019 
Printed
Page 30
2nd paragraph

Editra site is no longer available since July 2019: https://en.wikipedia.org/wiki/Editra

Note from the Author or Editor:
Starting at line 3 of the final paragraph on P30, the text relating to Editra should now read as follows, without the end of the sentence about downloading and locating the documentation. At the time of writing Editra development appears to have been discontinued, but you can download the last known fully working release for free at https://editra.en.softonic.com.

Charles  Sep 04, 2019 
PDF
Page 399
Example 17.2 <script>

The following lines of code need removing from the script else the browser will refuse to set them and throw an error request.setRequestHeader("Content-length", params.length); request.setRequestHeader("Connection", "close"); XMLHttpRequest isn't allowed to set these headers, they are being set automatically by the browser. The reason is that by manipulating these headers you might be able to trick the server into accepting a second request through the same connection, one that wouldn't go through the usual security checks - that would be a security vulnerability in the browser.

Note from the Author or Editor:
Yes, these two lines should be removed from the Example

Malenko  Sep 01, 2019 
Printed
Page 243
Example 10-6

Referring to this code, in example 10-6 if (isset($_POST['author']) && isset($_POST['title']) && isset($_POST['category']) && isset($_POST['year']) && isset($_POST['isbn'])) pg. 245 states "The first section of new code [shown above] starts by using the isset function to check whether values for all the fields have been posted to the program. " isset returns true when no value is submitted in the form. isset only triggers when the value being checked is NULL. To fix it, you can replace all the isset tests with !empty (not empty) so you can actually check whether values for all the fields have been filled in by the user before the user tries to write empty, garbage data to the database. The isset check, as it is currently written, checks for nothing at all, as far as I can tell.

Kyle Benjamin  Jul 23, 2019  Aug 09, 2019
Printed
Page 26
First paragraph under "Installing AMPPS on macOS"

URL given for downloading AMPPS is apachefriends.org (which is URL for XAMPP not AMPPS).

Note from the Author or Editor:
Correct the URL should be: https://www.ampps.com

Anonymous  Jul 14, 2019  Aug 09, 2019
PDF
Page 198
2nd paragraph

3rd line: "Because and is a stopword" 'and' is stopword for MyISAM search index. But we are (as instructed in the book) using here InnoDB seach engine where 'and' is not a stopword. Check: https://dev.mysql.com/doc/refman/8.0/en/fulltext-stopwords.html#fulltext-stopwords-stopwords-for-innodb-search-indexes

Note from the Author or Editor:
Replace the sentence: Because and is a stopword, MySQL will ignore it and the query will always produce an empty set - no matter what is stored in the columns With: If you are using the MyISAM storage engine, then because and is a stopword in that engine, MySQL will ignore it and the query will always produce an empty set - no matter what is stored in the column. Otherwise, if you are using InnoDB and is an allowed word.

Tomi Halonen  Jul 02, 2019  Aug 09, 2019
Printed
Page 60
Example 3-18

the statement is incorrect static $int = 1+2; //Disallowed (will produce a parse error) As per PHP 5.6 static $int = 1+2; // correct (as of PHP 5.6) reference: https://www.php.net/manual/en/language.variables.scope.php Thanks Luca Sabato

Note from the Author or Editor:
Correct. Please replace: static $int = 1+2; //Disallowed (will produce a parse error) With: static $int = 1+2; // correct (as of PHP 5.6)

Luca Sabato  May 30, 2019  Aug 09, 2019
Printed
Page 90
2nd paragraph

variable $j should be set to 11 in order to satisfy "For all values of $j between 10 and -10..." (as $j is decremented before the echo statement runs).

Steve Benson  Mar 16, 2019  Aug 09, 2019
Printed
Page 269
Example file: example11-2.php

Not sure if intentional or an error: Line 12 in the example file (example11-2.php): form method="post" action="formtest.php" Should be: form method="post" action="formtest2.php" formtest2.php - matches the example printed in the book

Note from the Author or Editor:
Fixed in the downloadable examples to match the book.

Anonymous  Feb 21, 2019  Aug 09, 2019
Printed
Page 28
Under the 'Installing LAMP on Linux' Section

The text tells you to download the linux version of AMPPS from apachefreinds.org. This is wrong as this the the home of XAMPP. I assume this was used in the previous addition and it was missed during checking for the new version.

Note from the Author or Editor:
Correct. The URL is: https://www.ampps.com

Peter Jones  Dec 28, 2018  Aug 09, 2019
Safari Books Online
Ch18
15th paragraph

Under the section "Using Classes" Problem: Missing apostrophe or sentence needs rewriting in the first sentence. The first sentence: The value of an id element must be unique within the web page, because that what lets it serve as an identifier. === Should be: The value of an id element must be unique within the web page, because that's what lets it serve as an identifier. ==== (I've underlines it, if you look at the text in a fixed width font.)

Note from the Author or Editor:
This was fixed during production.

Anonymous  Jan 08, 2018  May 08, 2018
Safari Books Online
Ch17
Example 17-2. urlpost.html

Coded HTML does not work at present Currently text says: params = "news.com" It needs to say: params = "url=news.com" The text describing the example refers to setting params to the name/value pair that will be posted to the PHP that responds to it.

Note from the Author or Editor:
This was fixed during production.

Anonymous  Jan 07, 2018  May 08, 2018