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
Printed Page 43
3rd line of code

While the general algorithm is correct, implementing the loop with foreach will not guarantee that the
$distribution array will be accessed from lowest to highest, resulting in incorrect weighting.

Anonymous 
Printed Page 105
last sentence

A piece of text from the Discussion section of section 4.3 seems to have been accidentally copied to the Discussion section of 4.2.
Starts with "In PHP 5.0.0 and above..."

Anonymous 
Printed Page 116
example 4.1

This concerns Example 4.1 on page 116 of edition II. Since 'switch' executes the statements that follow,
dare I say, on a 'case' by 'case' basis, one would really need to 'break' out of each case individually
- unless that's not the desired effect, of course.

Anonymous 
Printed Page 200, 201
Example 7-32, 7-33

The "$__data" array should be an associative array: $__data = array('person'=>'', 'email'=>'');

Anonymous 
Printed Page 222
near top of page

In order to illustrate using instanceof against an interface, the line:

if ($book instanceof Book) {

should read:

if ($book instanceof Nameable) {

Anonymous 
Printed Page 222
near top of page

In order to illustrate using instanceof against an interface, the line:

if ($book instanceof Book) {

should read:

if ($book instanceof Nameable) {

Anonymous 
Printed Page 241
function pc_parse_digest - 8th line from bottom of page

The first argument to preg_match includes the expression '(.*?)' which appears to be a mistake. Maybe '(.*)' was intended?

Anonymous 
Printed Page 256
Addition to the code on this page -- addition to my previous errata (below, p.257)

I also had to strip the slashes before displaying as well so

$text = wikiLinks($text);
// Display the page
echo $text;

becomes

$text = wikiLinks($text);
$text = (get_magic_quotes_gpc())?stripslashes($text):$text;
// Display the page
echo $text;

Anonymous 
Printed Page 257
Addition to the code on this page

This isn't a mistake as such but I believe that it is a very necessary addition.

The tiny wiki program is an excellent starting point for a cms system. However, a
php novice will be frustrated at the rapid proliferation of backslashes that the
entries accumulate due to magic quotes. Most php implementations now have magic
quotes enabled by default so this must be dealt with in the code.

I found that, to eliminate the slashes, I needed to call strip_slashes in the editing
module after fetching the page contents:

In function edit($page, $isNew = false) just after getting the contents to edit,
strip the slashes:

<?php } else {
$contents = file_get_contents(pageToFile($page));

becomes

<?php } else {
$contents = file_get_contents(pageToFile($page));
$contents = (get_magic_quotes_gpc())?stripslashes($contents):$contents;
}

If the slashes are not removed, they breed faster than rabbits!

Anonymous 
Printed Page 263
Example 9-5

if (isset($_POST['color']) && (strlen($_POST['color']) <=5 )) {
print 'Color must be more than 5 characters.';

First, there isn`t trim(). Should be so:
if (isset($_POST['first_name']) &&
(strlen(trim($_POST['first_name'])) <=5 )) {
print 'Color must be more than 5 characters.';
Because, the space is accepted to a character.

Then, there is a serious error:
if the variable isn`t in the array $_POST and it has less than 5 characters in it, if() return false but
in this case (in this expression) it must return true.

Anonymous 
Printed Page 266
4th line of Example 9-9

A comma is needed between the two arguments of preg_match.

Anonymous 
Printed Page 267
Example 9-10

Line 12 should read

$domain = "$sub_domain(\x2e$sub_domain)+";

(i.e. use '+' instead of '*').

Ironically, the 2nd paragraph of the discussion on that page mentions that the function "is useful for preventing a user from accidentally telling you that her email address is bingolover2261@example instead of bingolover2261@example.com", but the typo has de-activated exactly that part of the syntax check...

Anonymous 
Printed Page 270
last paragraph

Author fails to explain how one can "give the default choice a checked="checked" attribute."
He does not show it in his example. In fact, I don't think the author can display it
because there isn't anyway to include the attribute in the array. I haven't found it
anywhere in the entire chapter anywhere. Its not obvious and its not documented. Please
explain how to do what the author suggests.

Anonymous 
Printed Page 271
Example 11-8. Creating a parser

The example code won't function without these changes. The function "create_parser" uses a placeholder
for the name of the file, even though a $filename has been passed into the function.

Current publication: $fp = fopen('filename','r');

Should read: $fp = fopen($filename,'r');

Anonymous 
Printed Page 275
2nd line of Example 9-20

To produce the output shown, the single quotes surrounding fletch.html
in the assignment to $html should be escaped double-quotes.

Anonymous 
Printed Page 297
5th line down

in the Link to email addresses - in example 11-3. pc_ascii3html()

the preg_replace() replacement string should refer to $0 not $1, to replace the whole of the matched
pattern.

i.e.

'<a href="mailto:$1">$1</a>',$grafs[$i]);

should be:

'<a href="mailto:$0">$0</a>',$grafs[$i]);

Anonymous 
PDF Page 301
Example 10-10

The print statment prints with a non-existent variable called $row, when in fact it should have used the variable $firstRow.

Anonymous 
Printed Page 337
The one-sentence paragraph immediately preceding the "See Also" header

The sentence doesn't make sense at all. Not sure how best to fix it... the session_name() function doesn't return the name of a cookie at all.

Anonymous 
Printed Page 338
Both code listings

The line

$tokenstr = (str) date('W') . $salt;

is attempting to type cast the date() function's return value as a string, but the syntax is incorrect.
(str) should instead be (string):

$tokenstr = (string) date('W') . $salt;

Furthermore, this type casting is unnecessary because

1. date() returns a string
2. Concatenating date()'s return value with the $salt variable will also return a string.

This typo/error appears in both code listings on that page.

Anonymous 
Printed Page 352
Paragraph Solution

in regular expression, part for not permitting spaces in email has to be
[^@ ] in stead of [^@s].
Your favorite pattern does not allow the s character!

Anonymous 
Printed Page 354
whole chapter?

The downloaded examples for chapter 12 contain the XML output instead of the PHP
code. I assume that wasn't intentional?

Anonymous 
Printed Page 372, 373, 376 (twice), 378
After expression "new DOMDocument"

The semicolon at the end of the DOMDocument construction statement is missing.

Bernhard Bodenstorfer 
Printed Page 378
In the last block of code on the page

There are superfluous gt-entities "&gt;" in two lines of code:

[&#8230;]
$ab->&gt;load($file);
[&#8230;]
if ($ab->&gt;schemaValidateSource($schema)) {
[&#8230;]

Bernhard Bodenstorfer 
Printed Page 443
bottom

Didn't close your array.

Anonymous 
Printed Page 443
4th paragraph, first sentence

Where did the "10001" function argument come from? Should it just be removed entirely?

Anonymous 
Printed Page 494
Second full sentence on the page

The fourth word "to" should be removed maybe?

Anonymous 
Printed Page 512
First code section of the Discussion

The first and second lines of the code section: "$results = ..." and "foreach(..." are duplicated as the third and fourth lines.

Anonymous 
Printed Page 520
below second paragraph

<code>% php -r 'print strftime("%c");'</code> generates an error at the commandline
in Windows (XP with PHP 5.0). Only works for me if I type it as <code>php -r "print
strftime('%c')";</code> with the semi colon outside the quotes.

Anonymous 
Printed Page 534
The second code section in the Discussion

The first and second lines - "$transparent = ..." and "print_r(..." - are duplicated as the third and fourth lines.

Anonymous 
Printed Page 654
First sentence of recipe 22.8

Fifth word "characterssuch" is missing a space.

Anonymous 
Printed Page 664
Example 23-2

if(-1 == fwrite($fh, $_COOKIE['flavor'])) { die("can't write: $php_errormsg") };

should be

if(-1 == fwrite($fh, $_COOKIE['flavor'])) { die("can't write: $php_errormsg");}

The semi-colon is in the wrong spot!

David Schruth 
Printed Page 685
First sentence of recipe the 23.14 "Solution"

Extra word "print" following "print()".

Anonymous 


"If you are a PHP programmer, I know this is a book you probably should have sitting on your desk."
--Stefan Mischook, KIllersites.com