Errata


Print Print Icon

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



Version Location Description Submitted By
PDF Page --
--

I'd like to know where I should go from here, after reading the book. I'm mainly interested in OO PHP and Security. Thank you in advance!

23.12.2012 
Printed Page 16, 24
in PHP code examples

The report.html file saves the user's description of the aliens in a form field named "aliendescription". However, the report.php file tries to retrieve that information in variable $alien_description from $_POST['description'] whereas it *should* be $_POST['aliendescription'].

In the examples of the output from the PHP file execution, the description field is of course blank, because the description entered was not found by the PHP application. Oddly, this error has been corrected on page 22, but not pages 16 and 24.

You need to modify pages 16 and 24, substituting "aliendescription" for "description" in the PHP variable definition, and update the image of the PHP-generated confirmation on pages 13, 20 and 23 where the description field is blank.

Linda 
Other Digital Version 25
3rd paragraph

The paragraph says "If there is any PHP code in a web page, it's a good idea to name the file on the web server with .php, not .html". Actually, it is usually required to name it .php to tell the server to parse a script. .html pages will mostly not get parsed and will return the source code of the php script instead.

Anonymous 
PDF Page 26
1st paragraph

One extra "are" in the first sentence.

Peter McDonald 
Printed Page 33
1st paragraph

2nd sentence not complete:
$_POST already exists when your (..?)
this also applies to online and pdf version.

cocoboesch 
PDF Page 35, 36
Code lines referring to alien_description

Reference on p. 36, 3rd line of php code is presented as the correct form field name, but is missing underscore between "alien" and "description" that is present in every other instance across these 2 pages.

Peter McDonald 
PDF Page 41
echo code

Inconsistent form field names between pages using underscores between names here but on previous pages like p. 40 there are no underscores, i.e. "what_they_did" vs. "whattheydid"

Peter McDonald 
Printed Page 88
Chapter 2

The fourth point on the bullet points list contains a reference to the function mysqi_query(). The correct spelling is mysqli_query()

Maristella 
Printed Page 111
3rd paragraph

the "t" is missing in "execute", the book reads "execue".

Maristella 
Printed Page 125
first question of "there are no dumb questions"

one "e" is missing in "statement", the book reads "statment".

Maristella 
Printed Page 128
Near the bottom

The statement:

mysqli_query($dbc,$query)

is incomplete. It needs to be:

$result = mysqli_query($dbc,$query)

XJupiter 
Printed Page 171
2nd IF statement

The text indicates that we want to require input to both the subject and the text fields. The 2nd IF statement only outputs an error message if both fields are blank. The IF statement should use an OR, not an AND.

DJPJ 
Printed Page 171
Validation logic statements

$_POST['elvismail'] is assigned to the variable $text, but the validation logic statements use the variable $body.

lemuel 
Printed Page 171
full page

The name of the email body variable is inconsistent. At the top of the page and in the problem solution, it's referred to as $text, but in the logic examples it's referred to as $body.

Also, the header and the first paragraph are duplicated word-for-word from page 165.

Carl Jonard 
Printed Page 171
3rd and 4th paragraphs

There are two errors on this page:

1) IF $subject contains text AND $body contains text

This should be:

IF $subject contains text AND $text contains text

2) IF $subject is empty AND $body is empty

This should be:

IF $subject is empty AND $text is empty

XJupiter 
Printed Page 172
sharpen your pencil

Continuation of the same problem on page 171. If you use the logic in the book as is, then if subject is blank and text is filled in, no email will be sent and no error message will be given. Same thing if subject is filled in and the text field is blank.

DJPJ 
Printed Page 173-174
Sharpen your pencil

The same logic error as on 171 and 172.

DJPJ 
Printed Page 179
third and fourth code snippets

the third and fourth code snippets read

if (empty($subject) && (!empty($text))) {

if ((!empty($subject)) && empty($text)) {

they should read instead as follows:

if ((empty($subject)) && (!empty($text))) {

if ((!empty($subject)) && (empty($text))) {

Maristella 
Printed Page 186
Underneath "// We know both $subject AND $text are blank"

You are missing the echo statement below the following statement:

// We know both $subject AND $text are blank"

The echo statement should be:

echo 'You forgot the email subject and body text.<br />';

XJupiter 
Printed Page 188
5th coding line

The Author is missing one right parenthesis on the 5th coding line.

The line:

if (empty($subject){

Should be:

if (empty($subject)){

XJupiter 
Safari Books Online 189
End of Test Drive Description

There's a question mark missing from the last sentence.

David Friedman 
Printed Page 190
5th coding line

The Author is missing one right parenthesis on the 5th coding line.

The line:

if (empty($subject){

Should be:

if (empty($subject)){

XJupiter 
Printed Page 202
Last sentence in "Check to see if the form has been submitted" section

"Just make sure the 'submit' matches up with the id attribute of the Submit button in the form code." should say "Just make sure the 'submit' matches up with the name attribute of the Submit button in the form code."

I tried using the id attribute instead of the name attribute, and it did not work.

DJPJ 
Printed Page 203
Top right of page (the comment)

The first line of the comment is incorrect:

We check the value of $_POST"submit']

The line should be:

We check the value of $_POST['submit']


XJupiter 
Printed Page 204
Modified form code

Code as written results in "undefined variable" errors for both $subject and $text the first time the script is run. Setting both variables to null before checking for $_POST['submit'] is one solution:

$text = '';
$subject = '';
if(isset($_POST['submit'])) {

etc.

lemuel 
Printed Page 204
sample code at bottom of page

Sample code's textarea tag is indented <?php echo $text; ?> on next line, but doing so caused whitespace to be inserted in form's textarea on initial page load. If no body text is entered in the form, the spaces in the textarea still cause the $text variable to be "not empty" and the email is able to be sent despite the user not having entered any text there.

Removing the indentation got rid of the spaces and enable the validation to work properly again.

Anonymous 
Printed Page 211
ALTER TABLE statement

FYI .... I'm running MySQL 5.1.34, and the syntax that worked is:

ALTER TABLE email_list ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

DJPJ 
Printed Page 227
Left Center Comment

The comment:

After entering a name and score and clicking Add, the new score is confirmed and added to the guitarwars table in the database.

This should be changed to:

After entering a name and score and clicking Add, the new score is added to the guitarwars table in the database.

The new score at this point of the coding only gets added to the database, it DOES NOT GET CONFIRMED AND ADDED. The confirmation is performed by the Administrator at a later time by accessing the Admin page.

XJupiter 
Printed Page 235
mysql command line screen shot

sql statement is incorrect uses DESCRIBE email_list; should be DESCRIBE guitarwars;

Anonymous 
Printed Page 235
Test Drive

Before creating the table, you have to either create a new database, or decide to add the table to an existing database. Then you have to issue the USE statement; then you can run the CREATE TABLE and INSERT statements.

DJPJ 
Printed Page 236
First sentence

"With a new column added to the high score database,"?? The database is named "gwdb" and the table is named "guitarwars." I think it should say "With a new column added to the guitarwars table,"

DJPJ 
Printed Page 242
IF statemetn

filesize($row["screenshot'] should be filesize($row['screenshot']

DJPJ 
Printed Page 242
Near bottom of the page

The following line of code is incorrect:


if (is_file($row['screenshot']) && filesize($row["screenshot']) > 0) {

This should be:

if (is_file($row['screenshot']) && filesize($row['screenshot']) > 0) {

In other words "screenshot' should be 'screenshot'


XJupiter 
Safari Books Online 245
First Paragraph

Maybe this is clarified later on the text, but it says:

"you can't control the the initial storage location of uploaded files with PHP, which is why the location is considered temporary."

However, it is possible to do this in php.ini by changing upload_tmp_dir .

David Friedman 
Printed Page 251
addscore.php code lines with move_uploaded_file

It almost seems like a page is missing from the book, because it never actually shows you entering in code for a line that includes move_uploaded_file onto the addscore.php, (which makes this whole area confusing) but on page 251, it is there already inserted, while discussing the creation and integration of the GW_UPLOADPATH.

However, the code is incorrect. It is saying that the move_uploaded_file is a condition to test against, but it shouldn't be...

The line in the book is...

if (move_uploaded_file($_FILES['screenshot'][tmp_name'], $target)) {

and it should simply read...

move_uploaded_file($_FILES['screenshot'][tmp_name'], $target)

Jeff 
Printed Page 252
answer to making file names unique with adding time()

Adding the time() function to the $target variable will not work for the web site because it causes the name in the database to be different than the name of the actual picture file that is being saved in the images folder. The time function should be added to the

$screenshot=$_FILES['screenshot']['name'];

line of code, giving you...

$screenshot=time().$_FILES['screenshot']['name'];

This will allow the image to be named the exact same both in the images folder and the database table, and therefore in the index page it will properly reference the correct filename for the picture.

Jeff 
Printed Page 267
Top right comment

This line:

.....bytes is 1.22MB, or 1,250KB).

Should be replaced by:

.....bytes is 1.28MB, or 1,280KB).


XJupiter 
Safari Books Online 268
top

The description asks for less than the GW_MAXFILESIZE however the code is implemented as less than or equal to GW_MAXFILESIZE.

David Friedman 
Printed Page 269
code sample

Looks like we are testing for 4 error conditions, but only displaying a message for 3 of them.
The "if ($_FILES['screenshot']['error'] == 0 {" does not display an error if there was an upload problem, you just fall out and nothing happens.
The code that sounds like the right message for this condition is run if there is an error moving the uploaded file from the temp directory to the target. I think we need an appropriate message for this condition. Then by rearranging the '}' we can have the proper message for the upload error statement.

DJPJ 
Printed Page 269
Coding near the bottom

The following line:

.....(GW_MAXFILESIZE / 1024) . ' KB in size.</p>';

Should be changed to:

(GW_MAXFILESIZE / 32) . ' KB in size.</p>';

XJupiter 
Printed Page 322
ALTER statement

In my version of MySQL (5.1.34) adding the column 'approved' as TINYINT sets the value to NULL in all existing rows.

I re-did my ALTER to specify NOT NULL. That set the column value to 0 for all existing rows.
ALTER TABLE guitarwars ADD COLUMN approved TINYINT NOT NULL;

Now we can go through and approve them using the modified application.

Otherwise, they won't show up on the index.html page (because we are looking for a value of 1) and we won't create an 'Approve' link for those rows (because we are looking for a value of 0.)

I guess we could just look for a value of 1 or not 1, but that isn't how things are designed in the text.

DJPJ 
Printed Page 326
Sharpen your Pencil solution

if ( $row['approved'] == '0') should probably be
if ( $row['approved'] == 0) since approved is a TINYINT, but testing works both ways .... hhhmmmmm, interesting.

DJPJ 
Printed Page 339
Last paragraph /"Exercise" section

isnumeric should be is_numeric

Cathy Austin 
Safari Books Online 361
3rd grayed part of the code

in the line of code:

$query="SELECT user_id, username FROM mismatch_user WHERE username='$user_username' AND "."password=SHA($user_password)";

SHA($user_password) should be surrounded by single quotes.

The line of code should be:

$query="SELECT user_id, username FROM mismatch_user WHERE username='$user_username' AND "."password='SHA($user_password)'";

Sherif Mahmoud 
Printed Page 361
3rd gray part

Seems to be an issue with SQL statements spanning more than one line.
The code in the text kept failing, giving me an error about the SHA() function being undefined. Apparently, it was ending the SQL statement after the double quote at the end of the first line and not concatenating the rest of the statement. So the second line was executing, but it was only a fragment of a statement -- password = SHA('$user_password')";

I removed the concatenation and just let the statement wrap from one line to the next and it worked.

$query = "SELECT user_id, username FROM mismatch_user WHERE username = '$user_username' AND password = SHA('$user_password')";


DJPJ 
Printed Page 371

When conducting the "Test Drive" and adding a image i was getting an error stating "Notice: Undefined index: file ...editprofile.php line 60"
the error on this line looked something like this:
if ($_FILES['file']['error'] == 0) {

Corrected like this and the error goes away:
if ($_FILES['new_picture']['error'] == 0) {

jr_holland28 
Printed Page 403
Main Paragraph

There is a description of the php.ini setting "session.use_trans_id", which should be "session.use_trans_sid", according to the php manual.

lemuel 
Printed Page 403
middle of the paragraph

Here they talk about "session.use_trans_id". However, it should be "session.use_trans_sid". Small typo.

David Tang 
Printed Page 447
Second SELECT query of PHP & MySQL Magnets on line 6

The $query in the book and in the download code is: "SELECT topic_id FROM mismatch_topic ORDER BY category_id, topic_id"

The $query should actually read: "SELECT topic_id FROM mismatch_topic ORDER BY category, topic_id"

Basically, category_id should be replaced with category. Also shown on pages 448 and 456.


Rich dev 
Printed Page 456
Code section marked with 1

The query shows:

$query = "SELECT topic_id FROM mismatch_topic ORDER BY category_id, topic_id";

it should read:
$query = "SELECT topic_id FROM mismatch_topic ORDER BY category, topic_id";

The downloaded code also contains this error, line 29 in questionnaire.php.

Jim Munro 
Printed Page 456
In the code, Second"$query"

$query is set to equal "SLECT * FROM mistmatch_response ORDER BY category_it, topic_id".

Unfortunatley, category_id is not a field in the database, yet "category" is.

I'm not sure if this is a typo on the database end, or in the questionaire.php, but this needs to be fixed because it disables the script.

A fix for it is to change "category_id" to just "category" in the query.

Here is where a solution was posted:
http://forums.oreilly.com/index.php?s=&showtopic=3057&view=findpost&p=9596

Anonymous 
Other Digital Version 457
in the example code, not in the book I don't think

In the downloaded code of chapter 7.5 I got an error when submitting my profile picture.

The error was line 44 of the file: editprofile.php

Code was:
if ($_FILES['file']['error'] == 0) {

Code should be:
if ($_FILES['new_picture']['error'] == 0) {

Thanks for the great book!!

Jim Munro 
Other Digital Version 506
Downloadable SQL Database

The database does not import properly as it is on the server: entry number 12, Pet Food Tester, has the following description:

'We pride ourselves on how good our pet food tastes. Now you can help make our products even better. We&#8217;re hiring pet food tasters, apply now!'

Where it says "We&#8217;re", the mysql terminal confuses the apostrophy for a closing single quote. Changing it to "We''re" fixed this issue for me.

Laurel Raven 
Printed Page 508
Solution for "LIKE '%ma'"

In the magnet exercise solution, it only shows "Human Cannonball" and "Team Mascot" being a match for LIKE '%ma%'; however, since the LIKE term is case insensitive and % matches on anything INCLUDING nothing, it should also list "Matador" as a match.

Laurel Raven 
Printed Page 509
Speach/Thought Bubble at top

Poor wording choice:

"That last LIKE clause, LIKE '%Tipper Cow%', doesn't match anything because "Tipper" and "Cow" don't show up together as a phrase."

This is, as written, inaccurate: Tipper and Cow appear together as a phrase, but as "Cow Tipper". The thought bubble really should say something more like:

"That last LIKE clause, LIKE '%Tipper Cow%', doesn't match anything because "Tipper" and "Cow" don't show up together as a phrase in that order."

Laurel Raven 
Printed Page 544
Exercise Solution

I couldn't bring myself to put all that redundant code in my script.
Here's what mine looks like:

function generate_sort_links($user_search, $sort) {

$sort_links = '';
switch($sort) {
case 1:
$sortA = 2;
$sortB = 3;
$sortC = 5;
break;
case 3:
$sortA = 1;
$sortB = 4;
$sortC = 5;
break;
case 5:
$sortA = 1;
$sortB = 3;
$sortC = 6;
break;
default:
$sortA = 1;
$sortB = 3;
$sortC = 5;
}

$sort_links .= '<td><a href="' . $_SERVER['PHP_SELF'] . '?usersearch=' . $user_search .
'&sort=' . $sortA . '">Job Title</a></td><td>Description</td>';

$sort_links .= '<td><a href="' . $_SERVER['PHP_SELF'] . '?usersearch=' . $user_search .
'&sort=' . $sortB . '">State</a></td>';

$sort_links .= '<td><a href="' . $_SERVER['PHP_SELF'] . '?usersearch=' . $user_search .
'&sort=' . $sortC . '">Date Posted</a></td>';

return $sort_links;
}

DJPJ 
Printed Page 544
first paragraph

'sarch' should be 'search'

DJPJ 
Printed Page 546
Test Drive

When I take the test drive, I get an error "Notice: Undefined index: sort in C:\Inetpub\wwwroot\hfphp\ch09\riskyjobs\search.php on line 109.

I changed the code from
"$sort = $_GET['sort'];"

to

"isset($_GET['sort']) ? $sort = $_GET['sort'] : $sort = '';"

I got the same error when I ran the code I downloaded from your site.

DJPJ 
Printed Page 546
Test Drive

that should appear as $sort = ''; not $sort = ";"

I'm not sure why your errata form changed what I pasted in to it.

DJPJ 
Printed Page 549
Bottom paragraph, last sentence, above queries

The last sentence of the paragraph states "For example, here's how you get rows 11 through 25, which would be the third page of results." It should be 11 through 15 as the query is only set to return 5 results beginning at 11.

$query = $query . " LIMIT 10, 5";

Anonymous 
Printed Page 552
Code example and downloadable code for chapter

Hi, me again.

I noticed this earlier than was likely mentioned in the book, but the same error occurs in the downloaded code.

The line 144 in search.php is:
$sort = $_GET['sort'];

But the first sort will not have this variable sent in the GET so it shows an error:

Notice: Undefined index: sort in D:\wamp\www\search.php on line 141

I fixed it as you did with the page GET variable.

$sort = isset($_GET['sort']) ? $_GET['sort'] : '';

Jim Munro 
Printed Page 554
first paragraph

oops ... I typoed the page number related to this typo.

'sarch' should be 'search'

DJPJ 
Printed Page 577
(min,max) box

I think the last sentence should be removed ... "Here we're saying it should appear 2, 3, or 4 times in a row."

I don't see anything that supports that statement.

DJPJ 
Printed Page 587
Downloaded Source Code

Similar to error on 552. The registration form attempts to pre-populate the input fields with variables based on the $_POST data. The first time the script is run these variables do not exist and each field shows a php "Undefined variable" error.

Each field could use a ternary input such as
echo isset($first_name) ? $first_name : '';

lemuel 
Printed Page 618
middle of page

The description of the imagefilledellipse points to parameters 2 and 3 as width and height, and parameters 4 and 5 as x and y coordinates. It seems as though they are reversed. Parameters 2 and 3 should represent the x and y coordinates and parameters 4 and 5 should represent the width and height.

tmichael 
Printed Page 675
Downloaded Source Code

Line 49 of index.php has $row[last_name], should be $row['last_name'].

lemuel 
Printed Page 734
2nd paragraph

The book reads "To determine if you have MySQL on the Mac, open your terminal and type: cd /user/local/mysql

It should read
and type: cd /usr/local/mysql

as it is illustrated in the image of the terminal window below this passage.

Anonymous 
Safari Books Online 738
the link just above the last paragraph

It says to get version 6.0 or newer. The MySQL documentation page says, "Note: The MySQL 6.0 Reference Manual has been retired. MySQL 6.0 was not developed beyond Alpha status and new releases have not been made for some time, so the manual has been withdrawn as well."

Now what?

kajaco2