Learning PHP 5

Errata for Learning PHP 5

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 7
Example 1-2 HTML

The input tags should have been changed to read: <input type="text" name="user"/> and <input type="submit" value="Say Hello"/>

Anonymous    May 01, 2008
Other Digital Version
7
Example 1-2 HTML

The input tags should have been changed to read: <input type="text" name="user"/> and <input type="submit" value="Say Hello"/>

Anonymous    May 01, 2008
Printed
Page 10
example 1-7, line 12

$q = $dbh->query("SELEC...); NOW READS: $q = $db->query("SELEC...);

Anonymous    Nov 01, 2004
Printed
Page 10
Example 1-7, about halfway in the code listing

Missing () from if statement: if ($q->numrows == 0) { should be: if ($q->numrows() == 0) {

Anonymous    Nov 01, 2006
Printed
Page 11
5th paragraph

"Appendix B provides the basics of SQL." NOW READS: "Chapter 7 provides the basics of SQL."

Anonymous    Nov 01, 2004
Printed
Page 23
Paragraph 1

"The .2 formats $price + (1 + $tax)..." NOW READS: "The .2 formats $price * (1 + $tax)..."

Anonymous    Nov 01, 2004
Printed
Page 32
In Exercise 5,

The superscripts were mistakenly printed as "^1" and "^5" instead of just "1" and "5". THIS HAS BEEN CORRECTED.

Anonymous    Nov 01, 2004
Printed
Page 41
3rd paragraph, 2nd sentence

It returns a postive number if the first string is greater than the second string or a negative number if the first string is less than the first string" should be: It returns a postive number if the first string is greater than the second string or a negative number if the first string is less than the second string"

Anonymous    Nov 01, 2006
Printed
Page 50
Choosing a Good Array Name

"The first character of an array name must be a letter or number..." Should be: "The first character of an array name must be a letter or underscore..."

Anonymous    Sep 01, 2007
Printed
Page 56
the line before the last one

"print "Element 1 is How to Cook in Eat in Chinese"; NOW READS: "print "Element 1 is How to Cook and Eat in Chinese";

Anonymous    Nov 01, 2004
Printed
Page 73
last function definition (all optional arguments) half way down page

// All optional arguments function page_header6(... NOW READ: // All optional arguments function page_header7(...

Anonymous    Nov 01, 2004
Printed
Page 83
Code for exercise 5-3

The entire code example now reads: $cash_on_hand = 31; $meal = 25; $tax = 10; $tip = 10; while(($cost = restaurant_check($meal,$tax,$tip)) < $cash_on_hand) { print "I can afford a tip of $tip% ($cost) "; $tip++; } function restaurant_check($meal, $tax, $tip) { $tax_amount = $meal * ($tax / 100); $tip_amount = $meal * ($tip / 100); return $meal + $tax_amount + $tip_amount; } And the corresponding answer block in appendix C, section C.5.3 (page 303) now reads: I can afford a tip of 10% (30) I can afford a tip of 11% (30.25) I can afford a tip of 12% (30.5) I can afford a tip of 13% (30.75)

Anonymous    May 01, 2008
Other Digital Version
83
Code for exercise 5-3

The entire code example now reads: $cash_on_hand = 31; $meal = 25; $tax = 10; $tip = 10; while(($cost = restaurant_check($meal,$tax,$tip)) < $cash_on_hand) { print "I can afford a tip of $tip% ($cost) "; $tip++; } function restaurant_check($meal, $tax, $tip) { $tax_amount = $meal * ($tax / 100); $tip_amount = $meal * ($tip / 100); return $meal + $tax_amount + $tip_amount; } And the corresponding answer block in appendix C, section C.5.3 (page 303) now reads: I can afford a tip of 10% (30) I can afford a tip of 11% (30.25) I can afford a tip of 12% (30.5) I can afford a tip of 13% (30.75)

Anonymous    May 01, 2008
Printed
Page 88
HTTP_REFERER description

...don?t use it as your sole criteria for giving access... should be: ...don?t use it as your sole criterion for giving access...

Anonymous    Sep 01, 2007
Printed
Page 90
example 6-6

there is a missing parentheses in the 3rd line of the example, after '$_POST'. if (array_key_exists('my_name', $_POST); it should read: if (array_key_exists('my_name', $_POST));

Anonymous    Sep 01, 2007
Printed
Page 91
Example 6-7

Added the following text to the last paragraph on page 91: However, if your PHP configuration has error_reporting set to include E_NOTICE level errors, then you will see a message about _submit_check not being defined. If you want to suppress those messages, you can use array_key_exists().

Anonymous    May 01, 2008
Other Digital Version
91
Example 6-7

Added the following text to the last paragraph on page 91: However, if your PHP configuration has error_reporting set to include E_NOTICE level errors, then you will see a message about _submit_check not being defined. If you want to suppress those messages, you can use array_key_exists().

Anonymous    May 01, 2008
Printed
Page 92
3rd line in example 6-8

if ($_POST['_submit_check']) { NOW READS: if (array_key_exists('_submit_check', $_POST)) {

Anonymous    Nov 01, 2004
Printed
Page 96
Example 6-11

if ($_POST['age'] != strval(intval($_POST['age'])) { $errors[] = 'Please enter a valid age.'; } NOW READS: if ($_POST['age'] != strval(intval($_POST['age']))) { $errors[] = 'Please enter a valid age.'; }

Anonymous    Nov 01, 2004
Printed
Page 102
line 6; again in Figure 6-4

The Code block after the text "...then Example 6-22 prints:" now reads: I &lt;b&gt;love&lt;/b&gt; sweet &lt;div class=&quot;fancy&quot;&gt;rice&lt;/div&gt;&amp; tea. In figure 6-4: ...rice</fancy> & tea now reads: ...rice</div> & tea

Anonymous    May 01, 2008
Other Digital Version
102
line 6; again in Figure 6-4

The Code block after the text "...then Example 6-22 prints:" now reads: I &lt;b&gt;love&lt;/b&gt; sweet &lt;div class=&quot;fancy&quot;&gt;rice&lt;/div&gt;&amp; tea. In figure 6-4: ...rice</fancy> & tea now reads: ...rice</div> & tea

Anonymous    May 01, 2008
Printed
Page 105
Example 6-27

if ($selected_options[$option]) ... NOW READS: if (array_key_exists($option, $selected_options)) {

Anonymous    Nov 01, 2004
Printed
Page 106
Example 6-29. Form element display helper functions

//print a text box function input_text($element_name, $values) { print '<input type="text" name="' . $element_name .'" value="'; print htmlentities($values[$element_name]) . '">'; } NOW READS: //print a text box function input_text($element_name, $values) { print '<input type="text" name="' . $element_name .'" value="'; print htmlentities($values[$element_name]) . '"/>'; }

Anonymous    Nov 01, 2004
Printed
Page 106
Example 6-29 -Last function listed on page

In the example, the line if ($selected_options[$option]) { Should be changed to if (isset($selected_options[$option])) {

Anonymous    May 01, 2008
Other Digital Version
106
Example 6-29 -Last function listed on page

In the example, the line if ($selected_options[$option]) { Should be changed to if (isset($selected_options[$option])) {

Anonymous    May 01, 2008
Printed
Page 115
paragraph 5

"...the group of values for on particular dish..." NOW READS: "...the group of values for one particular dish..."

Anonymous    Nov 01, 2004
Printed
Page 116
First paragraph

At end of first line, "int his" NOW READS "in this"

Anonymous    Nov 01, 2004
Printed
Page 125
Code comment in Example 7-22

//Decrease the price some some dishes should be: //Decrease the price of some dishes

Anonymous    Sep 01, 2007
Printed
Page 130
Example 7-30

The code: // price must be a valid floating point number and // more than 0 if (floatval($_POST['price'] <= 0) { $errors[] = 'Please enter a valid price.'; } now reads: // price must be a valid floating point number and // more than 0 if (floatval($_POST['price'] <= 0)) { $errors[] = 'Please enter a valid price.'; }

Anonymous    May 01, 2008
Printed
Page 161
first code sample

ini_set('session.gc_maxlifetime',600'); // 600 seconds = = ten minutes now reads: ini_set('session.gc_maxlifetime',600); // 600 seconds = = ten minutes

Anonymous    May 01, 2008
Other Digital Version
161
first code sample

ini_set('session.gc_maxlifetime',600'); // 600 seconds = = ten minutes now reads: ini_set('session.gc_maxlifetime',600); // 600 seconds = = ten minutes

Anonymous    May 01, 2008
Printed
Page 186
5th paragraph

"If the submitted month is 10 and the submitted year is 2004, the call to mktime() is mktime(0, 0, 0, 11, 1, 2005):..." should be: "If the submitted month is 10 and the submitted year is 2005, the call to mktime() is mktime(0, 0, 0, 11, 1, 2005):..."

Anonymous    Nov 01, 2006
Printed
Page 187-188
both if ($_POST['_submit_check']) statements in Example 9-17.

Each instance of if ($_POST['_submit_check']) { now reads: if (isset($_POST['_submit_check'])) {

Anonymous    May 01, 2008
Other Digital Version
187-188
both if ($_POST['_submit_check']) statements in Example 9-17.

Each instance of if ($_POST['_submit_check']) { now reads: if (isset($_POST['_submit_check'])) {

Anonymous    May 01, 2008
Printed
Page 194
Example 10-1, line 3

The line if (date('H' >= 12)) { should read if (date('H') >= 12) {

Anonymous    Sep 01, 2007
Printed
Page 214
3rd paragraph

"sets $element_name to the name of an child" NOW READS: "sets $element_name to the name of a child"

Anonymous    Nov 01, 2004
Printed
Page 249
paragraph below the heading "Advanced Math"

The two superscripts were mistakenly printed as "^308" instead of just "308" THIS HAS BEEN CORRECTED.

Anonymous    Nov 01, 2004
Printed
Page 283
Table B-2,

In the last row of Table B-2, the third Column ("Matches"), it now reads: dog and cat and chicken, dog and cat and chickens, hotdogs and cats, dogs and cat and chickens, dog and cats and chicken, dog and cat and chickensoup, dogs and cats or chickens, dog and cat and chickenlegs and the fourth column ("Doesn't match") now reads: doggies and cats, dogss and catss

Anonymous    May 01, 2008
Other Digital Version
283
Table B-2,

In the last row of Table B-2, the third Column ("Matches"), it now reads: dog and cat and chicken, dog and cat and chickens, hotdogs and cats, dogs and cat and chickens, dog and cats and chicken, dog and cat and chickensoup, dogs and cats or chickens, dog and cat and chickenlegs and the fourth column ("Doesn't match") now reads: doggies and cats, dogss and catss

Anonymous    May 01, 2008
Printed
Page 292
Example B-8, last line of the example

'1 at 2', $members); NOW READS: '\1 at \2', $members);

Anonymous    Nov 01, 2004