Errata

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 29
3rd last paragraph

URL for FireFTP has changed. New address is:
http://fireftp.net

Jørgen W. Lang  Apr 18, 2015 
Printed Page 47
4th para

When demonstrating exclusive or with the following sample:

"$ingredient = $ammonia xor $bleach;"

I got bad results error running this code.

It seems that potentially the syntax changed since the writing of this edition, but per W3Schools (https://www.w3schools.com/php/keyword_xor.asp) you have to put the xor expression in parentheses.

Thus I would suggest it to be changed to the following:

"$ingredient = ($ammonia xor $bleach);"

Running this gave the expected output.


Charlie K.  Jul 03, 2021 
Printed Page 50 & 51
\t, \n, \r and example 3-8

The description of \t, \n, and \r as different spacings in the text formatting does not display in the web browser, this is also true of example 3-8. When tested in the browser as shown these do not produce a visual change in the formatting of the text. After a lengthy search, you must actually include " header('Content-Type: text/plain'); " after the initial " <?php " in order for the text formatting to correctly display in the browser.

Anonymous  Apr 09, 2020 
PDF Page 54
table 3-5

Sorry, not released, but actually end of life according to
http://php.net/eol.php

Jørgen W. Lang  Apr 18, 2015 
PDF Page 101
Warning regarding Example 5-4

The warning on page 101 says:

Passing by reference was deprecated in PHP 5.3.0 and was removed
in PHP 5.4.0. You should therefore not use this feature other than
on legacy websites, and even there you are recommended to
rewrite code that passes by reference, because it will halt with a
fatal error on newer versions of PHP.

Which seems to be in line with the official PHP documentation from:

http://php.net/manual/en/language.references.pass.php

that says:

Note: There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And as of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.

However, the peculiar thing is that, if I run the Example 5-4 on my Server using PHP 5.6.9, it executes just fine and displays everything well, without prompting an error message, like so:

WILLIAM henry gatES
William Henry Gates

This confuses me. The way I interpret the text is that this should not work. There should be an error. What is happening here?

Bern  Jun 04, 2015 
PDF Page 101
Note on the very top of the page

The entire "Do Not Pass Arguments by Reference" section is based on the mistaken belief that creating and using variable references is deprecated as of PHP 5.3.0. This is not the case. The following program will run just fine in versions of PHP above 5.3.0 without any warnings or errors. In other words, saying that the code in Example 5-4 is "no longer supported" is incorrect.

<?php

function increment(&$var) {
$var++;
}

$foo = 1;
increment($foo); // No error
echo $foo; // prints 2

$bar = &$foo; // No error
increment($bar); // No error
echo $foo; // prints 3
echo $bar; // prints 3

?>

I believe the source of confusion comes from the "Passing by Reference" page in the PHP docs (http://php.net/manual/en/language.references.pass.php) which states " As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And as of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error."

This does not mean passing by references is deprecated. Only call-time pass-by-reference is deprecated. It is still perfectly valid to specify in the function definition that the argument is passed by reference since this is not a call-time pass-by-reference. The following code showcases this difference:

<?php

function increment(&$var) { // Again, no error
$var++;
}

$foo = 1;
increment(&$foo); // error, call-time pass-by-reference
increment($foo); // No error since & is not used when calling the function

?>

Derek  Aug 14, 2015 
Printed Page 101
1st paragraph

Paragraph says that passing by reference was deprecated in PHP 5.3.0 and removed in PHP 5.4.0. It should say passing _references_ -- passing _by_ reference is allowed in later versions.
http://php.net/manual/en/language.references.pass.php

This may have an implication for the rest of that section, or not.

Will Briggs  Sep 26, 2016 
PDF Page 175
note on top of page

Link to documentation is deprecated (refers to MySQL 5.0, ten years old).

More current link is here:
http://tinyurl.com/mysql57grant

Jørgen W. Lang  Apr 24, 2015 
PDF, ePub Page 191
The paragraph right before Example 8-15

CHAPTER 8: Introduction to MySQL

Subtitle: Creating a FULLTEXT Index

The original text:
To create a FULLTEXT index, apply it to one or more records as in Example 8-15, ...

Should read as:
To create a FULLTEXT index, apply it to one or more columns as in Example 8-15, ...

NOTE: the same error is also found in the 5th Edition of this book.

R4D4  Dec 29, 2019 
Printed Page 213
table 9-3

There is a many-to-many relationship between book and authors. If this example included an author who had written more than one book his name would appear twice in Table 9-3, violating second normal form. This problem is not corrected elsewhere in the example.

Chris Sandvig  Feb 09, 2016 
Printed Page 241
Example 10-6

Great book so far. However, I think there's an error in the code published in example 10-6. I spent hours trying to debug this example and found that even the model code supplied by yourselves does not function as expected.

The following block:

if (isset($_POST['author']) &&
isset($_POST['title']) &&
isset($_POST['category']) &&
isset($_POST['year']) &&
isset($_POST['isbn']))
{
$author = get_post($conn, 'author');
$title = get_post($conn, 'title');
$category = get_post($conn, 'category');
$year = get_post($conn, 'year');
$isbn = get_post($conn, 'isbn');
$query = "INSERT INTO classics VALUES" .
"('$author', '$title', '$category', '$year', '$isbn')";
$result = $conn->query($query);

if (!$result) echo "INSERT failed: $query<br>" .
$conn->error . "<br><br>";
}

.......should not execute the insert query unless each field on the form has been populated. However, the fields can be blank but still supply a variable to $_POST - i.e. blank does not mean NULL.

I could only get this code snippet to work by replacing isset with !=' '.

Apologies, if I've overlooked something obvious and the fact that nobody else has picked this up makes me think I am missing something. However, as the sample code doesn't work, I think there may be something amiss.

Rob Johnson  Jan 04, 2016 
Printed Page 259
Example 10-19

The provided example gives the error 'Fatal error: Call to a member function bind_param() on boolean' after the prepare statement.

I noticed that the MySQL code in the prepare statement was not correct, resulting in the statement to return FALSE, which cannot be passed onto the bind_param statement and therefore giving the error. If you change the code

$stmt = $conn->prepare('INSERT INTO classics VALUES(?,?,?,?,?)');

for

$stmt = $conn->prepare('INSERT INTO classics(author,title,category,year,isbn) VALUES(?,?,?,?,?)');

the example works well.

Lisa  Mar 03, 2016 
Printed Page 296
Example 12-4

Hello,

Love your book, thank you.

Just a quick note. The login.php requirements change from example 12-3 to 12-4. In 12-3, the requirements are:

$hn
$db
$un
$pw

In 12-4 (and 12-5), they change to...
$db_hostname
$db_database
$db_username
$db_password

Once you know the problem, just add the new variables in the login.php and you are off and running. Don't see it and you get errors on the page.


Thank you.


Andrew Shaw

Andrew Shaw  Dec 27, 2015 
Printed Page 406
1st Para

In the 2nd sentence of page 406 it says at the end "urlget.html" and later "urlpost.html". (The full sentence is: "The end result of calling up urlget.html in your browser is identical to loading in urlpost.html."). However before it talks about how "urlget.php" and "urlpost.php" is being used and thus I think it should be changed to ".php" instead of ".html".

Charlie K.  Jul 03, 2021 
Printed Page 406
1st Para

The following errata is NOT an errata. Apologize for the report, it turns out this is correct and the below report written does not need to be executed.


Printed Page 406
1st Para
In the 2nd sentence of page 406 it says at the end "urlget.html" and later "urlpost.html". (The full sentence is: "The end result of calling up urlget.html in your browser is identical to loading in urlpost.html."). However before it talks about how "urlget.php" and "urlpost.php" is being used and thus I think it should be changed to ".php" instead of ".html".

Charlie K. Jul 03, 2021

Charlie K.  Jul 03, 2021 
PDF Page 627
Example 24-6 code

The URL used in the Flash fallback object, "http://tinyurl.com/html5video-mp4" leads to a 404 error:
"The requested URL /html5crashcourse/examples/lecture19/video.mp4 was not found on this server."

As the movie.mp4 file is already donwloaded on the local XAMPP server, it would probably better be http://localhost/movie.mp4 or sth.
Shouldn't it?

By the way, to force the Flash player on an HTML5 compatible browser, it is worth to comment the three following <source> lines, otherwise, the browser seems to choose his prefered option.

Best regards.

William Piette  May 01, 2015 
Printed Page 633
full page

geolocation for google maps api is not working anywhere in this book
I think it needs to be updated

Shahid Foy  May 17, 2016