Errata

Learning PHP, MySQL, JavaScript, and CSS

Errata for Learning PHP, MySQL, JavaScript, and CSS, Second Edition

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
ePub
Page 525
United States

Hello. Page 525 refers to the Kindle edition. The url's for downloading a MAMP appears to be out of date. Zend now provides a 30-day trial. Any suggestions to an alternative?

Thanks,
...Mark

Note from the Author or Editor:
You can follow the procedure in the following replacement Chapter 2 to install XAMPP instead:

http://lpmj.net/3rdedition/newc2.pdf

Anonymous  Jan 03, 2015 
Chapter 18
Pseudoclasses & Pseudoelements

I was confused about the difference between Pseudoclasses and Pseudoelements. I went to the provided link and I see that the book just had things a little mixed-up. Wikipedia was also helpful,

http://en.wikipedia.org/wiki/Cascading_Style_Sheets
"A pseudo-class classifies document elements, such as :link or :visited, whereas a pseudo-element makes a selection that may consist of partial elements, such as :first-line or :first-letter."

Note from the Author or Editor:
I have tightened up the explanation about he difference between pseudo classes and elements in future editions of the book.

Kris Jordan  Sep 14, 2013 
Chapter 19
RGB Colors & RGBA Colors

60% and 40% appear to be swapped in the two examples.

Note from the Author or Editor:
The two rgb() and rgba() examples should be as follows:

color:rgb(0%, 40%, 60%);
color:rgba(0%, 40%, 60%, 0.4);

Kris Jordan  Sep 14, 2013 
Chapter 13
Figure 13-3

<imf --> <img

Kris Jordan  Sep 14, 2013 
Chapter 13
Table 13-5

Example for !: role="strong" got in there somehow.

Kris Jordan  Sep 14, 2013 
Chapter 10
Example 10-19, Warning

mysql_escape_string --> mysql_real_escape_string

Kris Jordan  Sep 14, 2013 
Chapter 10
Deleting a Record, 3rd paragraph.

I don't see an else statement in the code.

Note from the Author or Editor:
Paragraph three in the section "Deleting a Record" should read:

If $delete didn?t contain the word ?yes,? then the following statements are executed. $query is set to an INSERT INTO command, followed by the five values to be inserted. The variable is then passed to mysql_query, which upon completion returns either TRUE or FALSE. If FALSE is returned, an error message is displayed.

Kris Jordan  Sep 14, 2013 
Printed
Page 251
1st paragraph

The last sentence of the paragraph says: "Example 10-19 illustrates how you would incorporate mysql_fix within your own code". However the function you create in both 10-18 and 19 calls the function mysql_fix_string, never mysql_fix.

Note from the Author or Editor:
In the paragraph before example 10-19, the function name referred to should read mysql_fix_string (not mysql_fix).

Charlie Cowan  Aug 11, 2013 
Printed
Page 483ish
"Bringing it all together"

I was just re-testing the "Social Networking Site" final project and found something odd in regards to one's username.

Essentially, the program will allow you to login (with correct password) in regardless of how certain letters are capitalized... which is ok, I guess

Problem:
1. The change shows in the "Messages"

for example:

User wrote: Bah bah

usER wrote: Etc. Etc.

USER wrote: Goose [erase]

(currently logged in as USER)

The next odd thing is that the way I type my username enables me to delete messages only from THAT username. For example above, if I login as "USER" only messages from "USER" can be erased. I have to log out and log back in as "User" to be able to delete under that name (again, password is the same and the system recognizes me as the same user).

I have tried to go back and modify as necessary, but, alas, made things worse. I'm still at it and hopefully before Robin gets back I'll post a response.

Note from the Author or Editor:
OK. this code will be updated in the next edition to prevent this anomaly. Thanks for the report.

Anonymous  Jun 30, 2013 
Printed
Page 224
1st & 2nd paragraph

So, I've been trying quit hard to get mysqldump to work and just when I was about to give up I wondered if there was an "issue" with zend itself.

Essentially, I was receiving the following error when I tried to get mysqldump to work on my mac osx terminal:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

My sleuthing found this blog:
A while ago I installed Zend Server Community Edition on OS X which was pretty straightforward. It was only recently that I found out that, as opposed to mysql which worked fine, mysqldump didn?t work correctly and terminated with the error:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

Inspecting the mysql configuration contained in /usr/local/zend/mysql/data/my.cnf confirmed that the section [client] showed the socket as returned by executing SHOW VARIABLES; from the mysql client: /usr/local/zend/mysql/tmp/mysql.sock

Although it is possible to specify the socket by using mysqldump?s --socket switch, that doesn?t really seem a ?solution?.

Apparently mysqldump, as opposed to the mysql client does not use the server-specific settings contained in /usr/local/zend/mysql/data/my.cnf. The comments in my.cnf state:

# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/zend/mysql/data) or
# ~/.my.cnf to set user-specific options.

After copying /usr/local/zend/mysql/data/my.cnf to /etc/my.cnf mysqldump worked as expected.

In /etc/my.cnf I have included only the setting needed to get mysqldump running:

# Specifying socket to use for mysql/mysqldump
# For other settings refer to /usr/local/zend/mysql/data/my.cnf
[client]
socket = /usr/local/zend/mysql/tmp/mysql.sock

Hope this saves anyone running into the same issue some time.

Update (alternative solutions):
As Joel Clermont pointed out it is also possible to create a symlink on the socket location expected by mysqldump to the real socket location. This can be done by executing:

ln -s /usr/local/zend/mysql/tmp/mysql.sock /tmp/mysql.sock

Another possible approach is to create a symlink at /etc/my.cnf to /usr/local/zend/mysql/data/my.cnf. This has the downside that it requires loosening the default permissions (drwxr-x---) on the data folder by allowing ?others? to enter it. Commands to execute:

sudo chmod o+x /usr/local/zend/mysql/data
sudo ln -s /usr/local/zend/mysql/data/my.cnf my.cnf

Granting more permissions can be a security consideration but on most development setups this probably won?t be an issue.

Long story short I typed in:
ln -s /usr/local/zend/mysql/tmp/mysql.sock /tmp/mysql.sock

then
mysqldump/usr/local/zend/mysql/bin/mysqldump -u USER -pPASSWORD publications

and FINALLY got it to work.

Note from the Author or Editor:
Thanks for your sleuthing. I will address this in the next edition of the book.

Tejas Mehta  Jun 04, 2013 
PDF
Page 172
3rd paragraph under Data Types

Under Data Types, the term "bytes" was used without an explanation as to what that is. A little bit further, the BINARY data type was explained using bytes, which only caused more confusion. Could you explain what bytes are? My guess is it's a measure of size but I need a little further explanation.

Note from the Author or Editor:
I will take your request under consideration for the next edition of the book. Essentially a byte comprises 8 bits and can have the values 00000000 through 11111111, which are 0 to 255 in decimal.

Anonymous  May 28, 2013 
Other Digital Version
140
Top of page

First paragraph

"Chapter 1. Introduction to Dynamic Web Conte"
"spread out across the wo"

I'm using the kindle edition(2nd edition) of the book and through out the book characters seem to have been cut off.

I've tried multiple devices ranging from PC, mac, iPad, Nexus 7 and all of them are showing the same issue.

I've deleted the book from my devices and re-downloaded it again, but it still shows the same issues.

Also with chapter 2 you might want to include this link http://files.zend.com/help/Zend-Server-6/content/installing_phpmyadmin.htm as the book talks about phpMyAdmin later on and yet phpMyAdmin is not installed during the zend server installation and needs to be installed as an app after that.

Note from the Author or Editor:
At one point there was apparently an error made in an ebook conversion of this book, but it was very quickly rectified. All copies should be fine now.

John Sofikitis  May 03, 2013 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page All of...
... the book

Since mid April 2013 there is now a newer second edition of Learning PHP, MySQL, JavaScript and CSS, in which Chapter 2 has been fully rewritten to account for major changes that have been made to the Zend web server used throughout the book.

Also, all known errata up until April 12th are corrected in this new edition, so only any shown below submitted after this date will apply if you have this edition of the book.

Robin Nixon
Robin Nixon
 
Apr 23, 2013 
Printed
Page 231
Example 10-2

When browsing the PHP documentation, I saw that the original MySQL extension was being deprecated in favor of the newer MySQLi extension. Aside from the object-oriented interface and some new features, how much does the new extension differ from the original?

This is a wonderful book. As a beginning web designer from Python and Java backgrounds, I've found it surprisingly simple to learn the basics of programming the Web 2.0. Thanks, Robin Nixon and O'Reilly!

Cheers,
Jordan

Note from the Author or Editor:
Indeed the MySQLi extension is now recommended in preference to the old MySQL procedural extension. However the old method is deprecated but will continue to be supported for some considerable time.

The next edition of this book will follow the latest recommendations, regarding MySQLi.

Jordan Reuter  Mar 25, 2013  Apr 12, 2013
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 14
All of Chapter 2

With the release of Zend Server 6, Zend Server Community Edition (Zend CE) has been replaced with a new product called Zend Server Free Edition. It offers all the same functionality (and more), but installs and sets up slightly differently than the manner described in the book.

Therefore the tinyurl.com link given for the previous product, doesn't work, but you can get the new free server from the following URL:

http://zend.com/en/products/server/free-edition

Or the shorter:

http://tinyurl.com/zendfree

To take this development into account I have completely rewritten Chapter 2 around the new Zend Server Free Edition, and have uploaded a PDF of the chapter to the following URL:

http://lpmj.net/ch02.pdf

Please refer to this version of the chapter instead, particularly if you're using a Mac, as the MySQL install is now actually a little easier because there's less command line configuring to perform.

- Robin Nixon

Robin Nixon
Robin Nixon
 
Mar 20, 2013  Apr 12, 2013
Printed
Page 284
under heading: "Ending a Session"

"you can use the session_destroy function in association with the unset function, as in Example 12-7."

Example 12-7 does not use an unset function!

Note from the Author or Editor:
The first paragraph under the Ending a Session heading should be:

When the time comes to end a session?usually when a user requests to log out from your site?you can use the session_destroy function, as in Example 12-7. This example provides a useful function for totally destroying a session, logging out a user, and unsetting all session variables.

N. David Blech  Mar 19, 2013  Apr 12, 2013
Printed
Page 89
1st paragraph

Describes the values of j$ being used for the calculation in the while loop on the previous page as "between 10 and -10" though the values used in the calculation are actually 9 to -10.

The vales going into the loop are 10 to -9 & are decremented by 1 before the calculation is performed.

Note from the Author or Editor:
Example 4-36 should be replaced with the following:

<?php
$j = 11;

while ($j-- > -10)
{
if ($j == 0) continue;
echo "$j " . (10 / $j) . "<br />";
}
?>

Anonymous  Mar 12, 2013  Apr 12, 2013
Printed
Page 239
1st sentence of the 2nd to last paragraph

"If $delete didn't contain the word "yes," the following else statement is executed."

This description does not match the current version of the code in Example 10-8. There is no else statement in the code, and the following if statement is entered regardless!

Note from the Author or Editor:
The third paragraph under the heading Deleting a Record should read:

If $_POST['delete']) is not set and so there is no record to be deleted, $_POST['author']) and other posted values are checked. If they have all been given values then $query is set to an INSERT INTO command, followed by the five values to be inserted. The variable is then passed to mysql_query, which upon completion returns either TRUE or FALSE. If FALSE is returned, an error message is displayed.

N. David Blech  Mar 11, 2013  Apr 12, 2013
Printed
Page 239
under the heading: "Deleting a Record"

"Having loaded up the various possible variables that could have been posted with any values that were passed, the program then checks whether the variable $_POST['delete'] has a value."

This description does not match the current version of the code in Example 10-8.



Note from the Author or Editor:
The first paragraph in the section Deleting a Record should read:

Prior to checking whether new data has been posted, the program checks whether the variable $_POST['delete'] has a value. If so, the user has clicked on the DELETE RECORD button to erase a record. In this case, the value of $isbn will also have been posted.

N. David Blech  Mar 11, 2013  Apr 12, 2013
Printed
Page 238
paragraph 2

"the first six lines"
This does not match the current version of the code in Example 10-8.

Note from the Author or Editor:
The second paragraph under Figure 10-2 should read:

The first section of new code starts by using the isset function to check whether values for all the fields have been posted to the program. Upon such confirmation, each of the lines within the if statement calls the function get_post, which appears at the end of the program. This function has one small but critical job: fetching the input from the browser.

N. David Blech  Mar 11, 2013  Apr 12, 2013
Printed
Page 17
1st paragraph

Although stated elsewhere that installation of Zend may change during the lifetime of this edition the problem I have requires more than common sense. Zend 6 no longer gives the option to download phpMyAdmin. Is this a problem? It would be nice to have an explanation on how to download and configure it manually.

Note from the Author or Editor:
A new Chapter two has been written to cover this, and is available at: http://lpmj.net/ch02.pdf

Anonymous  Mar 05, 2013  Apr 12, 2013
Printed
Page 217
1st paragraph (after figure)

"It contains is..."
The word "all" should be added at the begining of the sentence: "All it contains is..."

Note from the Author or Editor:
The paragraph under Figure 9-2 should read:

Table 9-12 is just such a table. It was extracted from Table 9-7, the Purchases table, but omits the purchase date information. It contains a copy of the ISBN number of every title sold, along with the customer number of each purchaser.

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 504
Chapter 8 Answers, number 3

"GRANT PRIVILEGES ON..."
This should be: GRANT ALL ON...

Note from the Author or Editor:
The answer to Q3 should be:

GRANT ALL ON newdatabase.* TO 'newuser' IDENTIFIED BY 'newpassword';

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 446-447
Example 19-4 & Figure 19-3

The title in the example ("Transitioning on hover") does not match the title at the top of the window in the figure ("CSS Rotate Example").

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 429, 431, 435, 446
Examples 19-1, 19-2, 19-3, 19-4

"<DOCTYPE html>"
The exclamation point is missing. It should be: <!DOCTYPE html>

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 424
last line of Table 19-1

"Pseudoelements p::first-letter"
There should be only a single colon, not two.

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 416
last paragraph

"The box model of an objectS"
should be: object

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 196
Example 8-28

"isbn VARCHAR(128),"
This should be 13 instead of 128.

Note from the Author or Editor:
Since ISBN-13 numbers are only 13 characters long, for efficiency line 3 of Example 8-28 should be:

isbn VARCHAR(13),

N. David Blech  Mar 04, 2013  Apr 12, 2013
Printed
Page 127
3rd paragraph

"the uppercase letter Q, the eighth element down and the FIFTH along..." This should read: FOURTH.

Note from the Author or Editor:
Yes, the word fifth should be fourth.

N. David Blech  Mar 04, 2013  Apr 12, 2013
Apendix D
Date Functions, DATE_ADD, examples

The Third line of example shows:
SELECT '2016-12-31 23:59:59' + INTERVAL 1 SECOND;

The results of this query show as:
2016-01-01 00:00:00

The Month and Day correctly updated but the year did not.

The results should show as:
2017-01-01 00:00:00

Note from the Author or Editor:
Yes, on page 526, towards the bottom, the year should show itself updated to:

2017-01-01 00:00:00

Kevan Sheridan  Feb 22, 2013  Apr 12, 2013
Printed
Page 34
Top of page first sentence in first paragraph in relation to Figure 2-21

"As you can see from Figure 2-21, Editra highlights the syntax appropriately using ""colors"" to help clarify what's going on."

*This page, and all other pages in this book with PHP code examples probably should have been printed in color for Figure 2-21 and other examples. I am guessing that the original master proof of this was in color and when it went to print everything was flattened to Black & White (Greyscale).

I selected Minor Technical Mistake because it will not lead anyone wrong, but since it states as you can see from the colors and its all in greyscale I figured this should be shared with you.

If this is in color in the PDF version that I see from the drop down of product formats and since I already bought this book New at Amazon.com, if a copy of this PDF in color is available, that would be greatly appreciated to use side by side with this book as well as when working on code.

By the way I am currently at chapter 3 and greatly enjoying this book to learn PHP with MySQL, JavaScript, and CSS. Just received it today in the mail. I have other older programming books by O'Reilly and I feel they are the best books out there to learn from and use as references on projects.

Thanks for taking the time to read this and possibly correct to color printed figures in a 3rd edition on the book.

Note from the Author or Editor:
in the next edition of the book I will note that you can see shades of grey in the figure in the printed version.

Dave Lembke  Feb 14, 2013  Apr 12, 2013
PDF
Page 108-109
Examples 5-14 and 5-15, inside User() and __construct() functions

Parse error: syntax error, unexpected 'public' (T_PUBLIC)

Example 5-14. Creating a constructor method
<?php
class User
{
function User($param1, $param2)
{
// Constructor statements go here
public $username = "Guest";
}
}
?>

and

<?php
class User
{
function __construct($param1, $param2)
{
// Constructor statements go here
public $username = "Guest"; //
}
}
?>

Visibility should be declared in the scope of the class definition:

<?php
class User
{
public function User($param1, $param2)
{
// Constructor statements go here
$username = "Guest";
}
}
?>

and

<?php
class User
{
public function __construct($param1, $param2)
{
// Constructor statements go here
$username = "Guest"; //
}
}
?>

See PHP Manual>Classes and Objects>Visibility:
http://www.php.net/manual/en/language.oop5.visibility.php

P.S. Thank you VERY much for your hard work on LPMJC, 2nd Ed.! Absolutely luculent material; would absolutely recommend to anyone interested in dynamic web design looking for a great introductory text on the subject! Looking forward to 3rd Edition...? 8)

Note from the Author or Editor:
Following are the corrected examples 5-14 and 15:

<?php // Example 5-14
class User
{
public function User($param1, $param2)
{
// Constructor statements go here
$username = "Guest";
}
}
?>


<?php // Example 5-15
class User
{
public function __construct($param1, $param2)
{
// Constructor statements go here
$username = "Guest"; //
}
}
?>

Louis R. Cost III  Feb 12, 2013  Apr 12, 2013
Printed
Page 472
end of a code on the top of the page

<br clear=left/> it should be <br clear='left'/>
Word left is without ' ' .

Note from the Author or Editor:
While the following (at the end of example 21-1) will work just fine:

<br clear=left />

It is always better to place arguments in quotes, like this:

<br clear='left' />

Victor Sheyanov  Feb 10, 2013  Apr 12, 2013
Printed
Page 401
Example 18-2

In both <div> objects inside <body> elements, there are missing the words "div" in the text that will be shown in the browser.

Note from the Author or Editor:
For the sake of total clarity, in Example 18-2 of LPMJC Ed 2 you could replace the following line:

<div>This text is within a tag</div>

with this one:

<div>This text is within a div tag</div>

Cesar Tellez  Jan 03, 2013  Apr 12, 2013
Printed
Page 126
Example 6-11

Creating a multidimensional numeric array for the chessboard example, there are two extra arrays. Should only be eight arrays not ten.

Note from the Author or Editor:
By crikey, you're right, two lines crept into the middle there.

For this example to work correctly readers should delete two of the lines that look like this (or use the correct file in the downloadable archive of examples):

array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '),

wayne f  Dec 03, 2012  Apr 12, 2013
Printed
Page 163
Paragraph beginning "So, to enter" halfway down

In the two commands supplied the program name of mysql is missing. The correct commands are:

"C:\Program Files\Zend\MySQL51\bin\mysql" -u root
"C:\Program Files (x86)\Zend\MySQL51\bin\mysql" -u root

Robin Nixon  Dec 01, 2012  Apr 12, 2013
Printed
Page 119
2nd Sentence

reads, "--if you are have ever used a strongly..."
instead of "--if you have ever used a strongly..."

Robert McFarlane  Nov 09, 2012  Apr 12, 2013
Printed
Page 105
Last sentence

Reads, "Let's add a more few lines..." instead of "Let's add a few more lines...."

Robert McFarlane  Nov 08, 2012  Apr 12, 2013
Printed
Page xvIII, 270
4:th paragraph, 1:st paragraph

Missing the Smarty chapetr that was in the first edition. There is however references to it in the second.

Note from the Author or Editor:
Please disregard this mention. Smarty is not covered in the 2nd edition due to its decline in general popularity and implementation. Unfortunately that sentence was not caught during proofing.

Bj?rn Larsson  Oct 25, 2012  Apr 12, 2013
PDF
Page 401
example 18.2

the style part of the example is not proper. it should be like:

<style>
div, span { border :1px solid black; }
div { background-color:yellow; }
span { background-color:cyan; }
</style>

Note from the Author or Editor:
Yes, the style section of Example 18-2 is incorrect, and should be:

div,span { border :1px solid black; }
div { background-color:yellow; }
span { background-color:cyan; }

netrananda  Oct 16, 2012  Apr 12, 2013
Printed
Page 510
End of list item 3 under 'Chapter 17 Answers'

(See Tables 18-1 and 18-2) should be (See Tables 17-1 and 17-2)

J Walker  Sep 29, 2012  Apr 12, 2013
Printed
Page 299
Last para - under 'Operators' heading

'the following statement outputs 16: document.write(13+2)' is incorrect - it outputs 15.

J Walker  Sep 23, 2012  Apr 12, 2013
Printed
Page 280
1st paragraph

Reference to Example 10-31 - this doesn't exist - should be 10.22.

J Walker  Sep 23, 2012  Apr 12, 2013