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
Other Digital Version
Kindle Locations 205-206

In the first example of PHP code to dynamically display the date, it is VERY easy to mistake the lowercase letter 'L' for the number '1,' so if the reader attempts to recreate the code on their own, it will not display correctly if they type 1 instead of l. A note should be included near the example that points out the distinction to avoid confusion.

Bill Dorr  Sep 01, 2015 
ePub
chapt 18 example 18-4

Example 18-4. Applying different positioning values <!DOCTYPE html> <html> <head> <title>Positioning</title> <style> #object1 { position :absolute; background:pink; width :100px; height :100px; top :100px; left :0px; } #object2 { position :relative; background:lightgreen; width :100px; height :100px; top :-8px; left :110px; } Question: in #object2 the value "top :-8px", was never explained. What does that mean?

Note from the Author or Editor:
The -8 was to compensate for different browsers. In the next edition of the book a container object is used to correctly constrain the inner objects instead.

Anonymous  Nov 14, 2015 
Safari Books Online
Ch 17
Using XMLHttpRequest section

Mention is made of an introduction to error handling, using the try…catch construct, supposedly made in the previous chapter (16). In actuality, this construct was mentioned not in that chapter, but in chapter 14, "Expressions and Control Flow in JavaScript”. In fact, chapter 17 has “Error Handling” as part of its title, when it isn’t really dealt with at all in that chapter, the sole focus being on data validation and regular expressions.

Note from the Author or Editor:
Thanks, you are correct. This is updated in the next edition.

Ethan Isenberg  Jun 20, 2017 
Printed
Page 17
Figure 2-1

XAMPP website download no longer includes "MySQL", but rather "MariaDB". This may be confusing to readers. MariaDB is a compatible replacement for MySQL

Note from the Author or Editor:
We now recommend the AMPPS stack at ampps.com

Gerald Tielke  Oct 24, 2015 
PDF
Page 26
code example on top

* DOCTYPE-declaration on beginning of HTML is mandatory. * lang-attribute for html-tag is considered best practice <!DOCTYPE html> <html lang="en"> <head> <title>A quickt test</title> </head> <body> Hello world </body> </html>

Jørgen W. Lang  Apr 18, 2015 
PDF
Page 28
section "Working remotely"

Usage of Telnet is highly insecure and should be avoided under all circumstances (except maybe for testing a HTTP connection from the command line).

Jørgen W. Lang  Apr 18, 2015 
PDF
Page 47
very bottom

The following statement in book: $ingredient = $ammonia xor $bleach; should be written as: $ingredient = ($ammonia xor $bleach); The additional parentheses are required due to operator precedence, as assignment holds tighter than xor. For instance, $ammonia = 0; $bleach = 1; $ingredient = $ammonia xor $bleach; echo $ingredient; print zero, even if it's obvious that result of 0 xor 1 is one. This is because the assignment statement is parsed as: ($ingredient = $ammonia) xor $bleach; hence $ingredient gets zero, than xor operator with $bleach results into one, but this operation is throwed out, as it operates in void context.

Note from the Author or Editor:
This is correct. The parentheses are required in this instance.

Grzegorz Szpetkowski  Jan 15, 2016 
Printed, PDF, Other Digital Version
Page 52
Example 3-9

In Example 3-9 when running the example exactly as printed in the book the PHP processor produces no output due to a missing statement (echo $out;)at the end of the code before the end of the PHP (?>). I will paste the code as it is in the book, then I will paste it again but will add the missing statement followed by a comment indicating that this is where I've added my correction like this: "// This is where I've added my correction to make the code work" Example 3-9 as it's printed in the book: ------------------------------------ <?php $author = "Scott Adams"; $out = <<<_END Normal people believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet. - $author. _END; ?> ------------------------------------ And with the correction needed to produce results. ------------------------------------ <?php $author = "Scott Adams"; $out = <<<_END Normal people believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet. - $author. _END; echo $out // This is where I've added my correction to make the code work ?> ------------------------------------ I'm a new programmer, to begin with, and am completely new to PHP, and couldn't figure out why something from a book wouldn't run, until Ah hahh, using knowledge from the book I found the problem. I guess according to example 3-8 I am smart enough to debug... Thanks for your attention. Matthew Lagasse

Note from the Author or Editor:
The following statement requires adding immediately prior to the closing ?> tag of Example 3-9: echo $out;

Matthew Lagasse  Jan 19, 2015  Apr 03, 2015
PDF
Page 66
last bullet point

The unary negation operator is ! (an exclamation mark), not a minus sign (-).

Jørgen W. Lang  Apr 19, 2015 
PDF, ePub, Mobi
Page 68
Above Table 4-2

There is an extra space between "prece" and "dence", so the original Table 4-2 lists PHP’s operators in order of prece dence from high to low. should be Table 4-2 lists PHP’s operators in order of precedence from high to low.

Note from the Author or Editor:
Yes, the occurrences of prece and dence should be replaced with the single word precedence.

Toby Wei  Jan 26, 2015  Apr 03, 2015
PDF
Page 89
2nd sentence

"We’ll look into the file-handling commands in a later chapter,…" Suggestion to change 'later chapter' to 'chapter 7', so it can be linked in non-printed versions.

Jørgen W. Lang  Apr 19, 2015 
PDF
Page 89
3rd paragraphs first sentence

In the book the keyword global (not $_GLOBAL) is defined as way of declaring global variable. It's way of ACCESS variable from global scope. Outside of a function it's only used in included files to access parents global scope.

Anonymous  Jun 26, 2015 
PDF
Page 101
example 5-4 caption

"Returning values from a function by reference" should be "Passing values to a function by reference".

Jørgen W. Lang  Apr 19, 2015 
Printed
Page 107
Figure 5-3

Figure 5-3 text "A jukebox: a great example of a self-contained object". The graphic appears incorrect since it displays of a match box, not a jukebox. Please post a revised graphic on this website with appropriate symbols documenting a jukebox as a self-contained object.

Note from the Author or Editor:
In previous editions there used to be a picture of a jukebox here, but it has been accidentally dropped in the 4th edition. The correct image is here: http://lpmj.net/images/f5-03.png

Stepeh Rynas  Mar 12, 2015  Apr 03, 2015
PDF
Page 108
section "Creating an object", 1st sentence

Missing dollar sign before 'object': "like this: object = new Class. " should be "like this: $object = new Class. "

Jørgen W. Lang  Apr 19, 2015 
PDF
Page 108
last sentence

"A class may require or prohibit arguments; it may also allow arguments but not require them." On first and second read the above appears self-contradictory. May I suggest to change the wording to something like: "A class may require or prohibit arguments; it may also allow arguments without explicitely requiring them."

Jørgen W. Lang  Apr 19, 2015 
PDF
Page 114
3rd last paragraph

"…because PHP implicitly declares the variable $object1->name for you." should be "…because PHP implicitly declares the property $object1->name for you."

Jørgen W. Lang  Apr 19, 2015 
PDF
Page 118
1st paragraph, last sentence

"You achieve this using the extends operator." should be: "You achieve this using the extends keyword."

Jørgen W. Lang  Apr 19, 2015 
Printed
Page 121
United States

Post-chapter questions include the seemingly nonsensical sentence "This is a second sentence in the list" after questions 1, 3, 5, and 10.

Note from the Author or Editor:
Thanks - very weird how that got there - all occurrences should be deleted.

Bob Reap  Jan 29, 2015  Apr 03, 2015
PDF
Page 126
last paragraph

"…format index => value. " Suggestion to replace 'index' with 'key' for easier distinction between associative and index-based (numerical) arrays.

Jørgen W. Lang  Apr 19, 2015 
PDF
Page 144
warning, last sentence

Update suggestion: Most computers now support DateTime (are 64-bit capable).

Jørgen W. Lang  Apr 20, 2015 
PDF
Page 145
section "Time specifiers"

format "G" does not have a leading zero, but "H" does

Jørgen W. Lang  Apr 20, 2015 
PDF
Page 146
example 7-3

Text uses February as an example, but sample code uses September.

Jørgen W. Lang  Apr 20, 2015 
PDF
Page 161
3rd line

The else statement in Example 7-17 is not closed. It should be foreach($output as $line) echo htmlspecialchars("$line\n"); echo "</pre>"; } ?> instead of foreach($output as $line) echo htmlspecialchars("$line\n"); echo "</pre>"; ?>

Anonymous  Sep 22, 2016 
PDF
Page 170
section "MySQL on a remote server", 1st sentence

Suggest to change wording to not use Telnet at all, like: If you are accessing MySQL on a remote server, you connect to the remote machine via SSH…

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 175
example 8-3

Sample code explicetely uses MyISAM (for later use of fulltext indexes). New standard is InnoDB which also supports fulltext. Code could be simplified.

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 178
table 8-7 1st entry

BINARY(n) or BYTE(n): There is no data type "BYTE" in MySQL (but in Oracle). The term "CHAR_BYTE" exists in MySQL as an alias for BINARY.

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 181
top heading

AUTO_INCREMENT is not a data type but an attribute.

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 187
2n last paragraph, 1st sentence

"And finally, I set no limit to the year column’s index, because it’s an integer, not a string." but "year" is defined as data type CHAR. I suggest to change the sentence to: "And finally, I set no limit to the year column’s index, because it has a clearly defined length of 4 characters."

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 189
last sentence

…uses the UPDATE and WHERE keywords… should be …uses the UPDATE command and WHERE keyword…

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 191
Half way

The book states: "FULLTEXT indexes can be used only with MyISAM tables" This is incorrect, InnoDB tables can also have FULLTEXT indexes in MySQL5.6.

Note from the Author or Editor:
This bullet point should be updated by inserting the following in front of the existing text: Since MySQL 5.6 InnoDB tables can use FULLTEXT indexes, but prior to that

Jasper Kips  Jan 24, 2015  Apr 03, 2015
PDF
Page 192
section "SELECT" 1st paragraph, 2nd last sentence

"…because all the data will scroll by at an unreadable pace…" This can be solved by using the MySQL command: > pager less; Reset pager to STDOU by > nopager;

Note from the Author or Editor:
On Unix/Linux boxes this will work.

Jørgen W. Lang  Apr 24, 2015 
PDF
Page 195
Example 8-21, 2nd SELECT

isbn="9781598184891 "; Example (also downloadable code) contains an additional space before the closing double quote.

Jørgen W. Lang  Apr 24, 2015 
PDF, ePub, Mobi
Page 202
Figure 8-17

In Figure 8-17, the command to create table "customers" contains a wrong length of the column "isbn", which is supposed to be of 13 characters. In that figure it shows "VARCHAR(128)" in stead of the actual command offered "VARCHAR(13)."

Note from the Author or Editor:
Good catch. The corrected figure can be found at: http://lpmj.net/images/f8-17.png

Toby Wei  Jan 26, 2015  Apr 03, 2015
Printed
Page 203
Regno Unito

Hello, this book is very well done, I have spotted a little error in the Example 8-29 where the command is not consistent with the initial recommendation of the author related to capital letters to distinguish the SQL code from the names of the database tables, columns, and rows names.(page 173, first bullet). The command: SELECT name,author,title from customers,classics WHERE customers.isbn=classics.isbn; should be instead: SELECT name,author,title FROM customers,classics WHERE customers.isbn=classics.isbn; With 'FROM' in capital letters, as it does refer to a SQL command.

Note from the Author or Editor:
Yes, although the example still works, ideally the first line of Example 8-29 should be: SELECT name,author,title FROM customers,classics

Alessandro Coraglia  Jan 10, 2015  Apr 03, 2015
Printed
Page 228
4th paragraph

Hello, I am reading every word and doing each of the examples. Wonderful book! Things are clicking in programming where they have never clicked before. When referring to mysqldump, it would be very helpful to tell the user to exit the program first. My suggestion is in addition to the example, add exit as a line, so it would look like: exit mysqldump -u user -ppassword publications Thank you! Sincerely, Andrew Shaw

Andrew Shaw  Dec 26, 2015 
PDF, ePub, Mobi
Page 244
Bottom of the page (last two lines)

An extra parenthesis on the right of both $_POST['delete'] and $_POST['author']. So the original $_POST['delete']) ... $_POST['author']) ... should be $_POST['delete'] ... $_POST['author'] ...

Note from the Author or Editor:
Thanks, yes, the right hand parenthesis should be deleted after each occurrence of the right hand square bracket on these two lines.

Toby Wei  Jan 26, 2015  Apr 03, 2015
Printed
Page 253
Line 13

Code currently reads: echo "The Insert ID was: " .$result->insert_id; This results in an error message: "Trying to get property of non-object" Code should read: echo "The Insert ID was: " .$conn->insert_id;

Note from the Author or Editor:
In Example 10-14 this line: echo "The Insert ID was: " . $result->insert_id; Should be replaced with: echo "The Insert ID was: " . $conn->insert_id; Also, near the bottom of the page, the line that reads: $insertID = $result->insert_id; Should be changed to: $insertID = $conn->insert_id;

Les Ansley  Jan 15, 2015  Apr 03, 2015
PDF
Page 255
Example code

The code of additional query is as follows: $subresult = $conn->query($query); Should be rather $subresult = $conn->query($subquery); Otherwise it again refers to the first query and doesn't produce expected results.

Note from the Author or Editor:
In Example 10-15 this line: $subresult = $conn->query(query); Should be replaced with: $subresult = $conn->query($subquery);

Piotr Cieślak  Jan 19, 2015  Apr 03, 2015
Printed
Page 279
3rd paragraph

Running Example 11-10 a capital A with a tilde on top appears between the $f and $c variable output: "23 [tildeA] [degree sign]f equals -5 [tildeA] [degree sign] c" appears as the result in the browser. Im not sure this is important, but it would be nice to know why.

Note from the Author or Editor:
Replace the degree symbol with the &deg; HTML entity and this should not happen.

Anonymous  Jan 09, 2016 
Printed
Page 281
last paragraph

"implanted" should be "implemented" (presumably)

Note from the Author or Editor:
Correct - thanks for spotting this.

Bob Reap  Jan 31, 2015  Apr 03, 2015
PDF
Page 294
Last paragraph

A little bit of purism here, but in the hashing discussion, it is said: "Salting is simply a matter of adding some text that only we know about to each parameter to be encrypted." It should probably say "hashed" instead of "encrypted," since encryption is usually contrasted with hashing with the one/two-way function difference.

Anonymous  Apr 17, 2016 
Printed
Page 295
Example 12-3

In example 12-3 the "login.php" file that was created earlier in the book is used in the code to create and populate a new table however on line 4 of the example the mysql log-in details are referenced as below: ... new mysqli($db_hostname, $db_username, $db_password, $db_database); Which will cause an error. They should be as follows: ... new mysqli($hn, $un, $pw, $db);

Note from the Author or Editor:
You are correct, the third line of Example 12-3 should read: $connection = new mysqli($hn, $un, $pw, $db);

Tessa Lake  Feb 21, 2015  Apr 03, 2015
Printed
Page 300
Regno Unito

Hello Robin, I think there is an error in the last statement in bold where the original is: <a href=continue.php> and I believe it should be: <a href='continue.php'> Not such a horrible issue though... above all if I can spot it :o)

Note from the Author or Editor:
This is not exactly an error because all browsers allow URLs to not be encapsulated in quotation marks. However, to show best practice, I agree that the URL should be quoted.

Alessandro Coraglia  Jan 30, 2015  Apr 03, 2015
PDF, ePub, Mobi
Page 314
Bottom of the page

The example caption of Example 13-7 is showing an error message from Apple Safari console, so the original Example 13-7. An Opera Error Console message should be Example 13-7. An Apple Safari Console message

Note from the Author or Editor:
The heading for Example 13-7 should read: Example 13-7. An Apple Safari Console message

Toby Wei  Jan 26, 2015  Apr 03, 2015
PDF, ePub, Mobi
Page 329
2nd paragraph of 2nd section

There is a multiple word "have" in "You may, however, have have heard that ... "

Note from the Author or Editor:
Yes, the second 'have' should be deleted.

Toby Wei  Jan 26, 2015  Apr 03, 2015
PDF
Page 372
Example 16-1

The CSS class .signup is defined but not used. To get the same result as Figure16-1 the property class="signup" should be added to the <table> tag.

Note from the Author or Editor:
The first line of HTML in the <body> section should read: <table class="signup" border="0" cellpadding="2" cellspacing="5" bgcolor="#eeeeee">

Alessio Ulzi  Mar 16, 2015  Apr 03, 2015
PDF
Page 375
Example 16-2

The function isNaN returns false when an empty string is passed because JavaScript interprets it as a 0. So inside the validateAge function the first check should be something like if (field == "" || isNaN(field)) return "No Age was entered.\n" to get the same result as Figure 16-2

Note from the Author or Editor:
That is interesting. Indeed, tests confirm that isNaN() treats the empty string as if it were a number. Your solution to this is correct: Simply replace the first line of the function validateAge() with: if (field == "" || isNaN(field)) return "No Age was entered.\n"

Alessio Ulzi  Mar 16, 2015  Apr 03, 2015
Printed
Page 388
Last line of code and continuing on the following page

This comment applies to both the printed text and to the downloaded file. The PHP code for example 16-3 contains JavaScript within a heredoc structure. All of the return text value from the JavaScript contain '\n' line feed instructions. This code works fine where it is created in example 3-1 but when it is copied into example 3-1 as a 'heredoc' between '<<<_END' and '_END;' PHP parses the code across two lines and the JavaScript onsubmit validation call fails with an 'un-terminated string' and only the PHP validation is active. The '\n' should be double escaped i.e. '\\n' to prevent this happening. There is a dozen occurrences of this error across pp388 & 389.

AJB  Feb 12, 2016 
Printed
Page 457
Figure 19-2

Figure 19-2 is supposed to show an Employee of the Month certificate, as coded in Example 19-1. Instead, it is a picture of browser configuration dialogs.

Anonymous  Feb 20, 2016 
Printed
Page 481
After 1st paragraph of "The C Function" section

The closing tag of the <div> element is written </fiv> (instead of the correct </div>).

Note from the Author or Editor:
The </fiv> tag should read </div>

Simo   Mar 28, 2017 
PDF, Other Digital Version
Page 547
4th para

the text mentions the name of the method as filtert whereas the example has the name of the method as filter.

Ashish Gupta  Sep 01, 2016 
PDF
Page 594
10th line

240,20 should be 240,240. "Then an arc is drawn using imaginary tangent lines from that location to position 240,20, and from there to location 460,20." I found it confusing me, so I guess 240,240 will be reasonable.Thanks for your attention. Yuxin Sun

Yuxin Sun  Oct 02, 2015 
Printed
Page 664
bottom paragraph

On page 664 of the book, bottom paragraph it reads "See chapter 13 for more details on how to do this", they are referring to hashed passwords. problem: chapter 13 does *not* contain any such information ,its actually found in chapter 12

Note from the Author or Editor:
Thanks - the correct Chapter is, indeed, 12.

claudio izzi  Jan 31, 2015  Apr 03, 2014