Errata

Web Database Applications with PHP and MySQL

Errata for Web Database Applications with PHP and MySQL

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
Printed Page None
Winestore

This has already been documented in other reviews...but I still don't know how to fix the problem with the customhandler.inc file.

The author's website displays a similar error. The error on my installation says

Catchable fatal error: Object of class winestoreTemplate could not be converted to string in /var/www/wda2-winestore/includes/customHandler.inc on line 44

I understand this is a difference between the version of PHP this book was written for and the current version of PHP available, but could I find out how to correct this error? I'm just learning....and have searched the php.net pages...but can't find the solution.

Thank you

Bryan O'Brien  Jun 13, 2009 
Printed Page none
Winestore application Error in customHandler.inc

I too was getting the fatal error coming from customHandler.inc, presumably due to using PHP 5.2. I have come up with a psuedo fix, although I wish I understood the real fix. By commenting out the backTrace() function declaration and the call to it on line 77 the initial application page error is gone. Also, you have to comment out the call to set_error_handler() in each of the display files. This is not an ideal solution, but my winestore app now works. I'm still researching ways to get this app to work with PHP5 but am unsuccessful so far.

Anonymous  Dec 18, 2010 
Printed Page 7
Last paragraph on p. 7, continuing on p. 8.

The description of "servers" could use a bit of clarification (for some audiences). The concept of
the "web server" has, up to this point, been depicted in various figures as a hardware box that
looks like a typical PC. This paragraph describes a server as a set of programs, one of which
coordinates the others. The paragraph goes on to describe the "starting of new servers" (What?
Another hardware box?) and the "killing of unused servers" (How do you "kill" a piece of
hardware?).

This could be a mystery unless the reader understands the concept that the "the server" is "a set/
collection of intercommunicating processes/programs, i.e., software, that is/are running on one or
more computers", and that the controlling/coordinating process has the ability to dynamically
create/spawn/give birth to additional processes, and destroy them, in order to share the load.

Anonymous   
Printed Page 18
Middle of page, end of 3rd list item

Grammatically incorrect phrase: "statements can be distribute code across multiple blocks of code."

Anonymous   
Printed Page 41
6th paragraph, 1st edition

Following the text 'It's also common for the else clause to execute a block of statements
in brackets ...'

It seems to me that the 'true' and 'else' are reversed. i.e., 'if ($var > 5) should echo
"Variable is greater than 5"

Anonymous   
Printed Page 49
middle of 1st paragraph

Used "to" instead of "too" in "The effect is a bit to hard to understand... "

Anonymous   
Printed Page 77
2nd paragraph

The description of printf states that it will "truncate" floating point numbers.
This is wrong. It rounds them. As does the same function in C.

This error is repeated on page 79 in example 3-2. The first line will output: "Over
55.72% of statistics are made up." The comment states that the number will be 55.71
because it assumes that the argument 55.719 will be truncated rather than rounded.

Anonymous   
Printed Page 81
paragraph 2 (paragraph numbers ignores code listings)

Book says: "Both strcmp() and strncmp() take two strings as parameters, str1 and
str2, and return 0 if the strings are identical, 1 if str1 is less than str2, and -1
if str1 is greater that (sic) str2."

This is incorrect. strcmp() returns -1 if str1 is LESS than str2, and 1 if str1 is
GREATER than str2. (Just before the above, the prototype of strcmp shows str1 as the
first argument to strcmp, and str2 as the second argument.)

Anonymous   
Printed Page 81
2nd paragraph of section "Comparing Strings"

"Both strcmp( ) and strncmp( ) take two strings as parameters, str1 and str2,
and return 0 if the strings are identical, 1 if str1 is less than str2, and -1
if str1 is greater that str2."

"1 if str1 is less than str2, and -1 if str1 is greater that str2"
is inconsistant with examples below on same page:

print strcmp("aardvark", "zebra"); // -1
print strcmp("zebra", "aardvark"); // 1
print strcmp("mouse", "Mouse"); // 1
print strncmp("aardvark", "aardwolf", 5); // -1

Examples are correct and statement is wrong.

Anonymous   
Printed Page 87
Last Paragraph

All POSIX regex functions were deprecated over a year ago.

Mike Hudson  Aug 23, 2010 
Printed Page 90
Sec. 3.3.1.4. Optional and repeating characters

In 3.3.1.4. Optional and repeating characters:

********************************************
$hexString = "x01ff";

// True for strings that start with 'x' followed by at least
// one hexadecimal digit
$matches = ereg('x[0-9a-fA-F]+$', $hexString); // true

********************************************
This regexp should begin with '^' to match strings
that start with 'x'...

Anonymous   
Printed Page 92
end of page

The string $phone is not completely verified, only the first four (or five) characters. This, of course, may have been the author's intention.

Alex Edwards  Jun 01, 2009 
Printed Page 93
2nd piece of code

The backslash doesn't have to be quoted, at least not with PHP 5.2. I find that ereg('^[a-zA-Z \]*$', 'The backslash \ character') works admirably.

Alex Edwards  Jun 01, 2009 
Printed Page 98
4 lines from end

Example gives:

$var = strtotime("14/5/1955")

The strtotime function takes a US format date, so this should be given as:

$var = strtotime("5/14/1955")

Anonymous   
Printed Page 119
__destruct function in example 4.6

The destructor uses $donation, but this only exists as a value for the constructor. Hence it
creates an "undefined variable" error.

Donation::$totalDonated = Donation::$totalDonated - $donation;

should be replace with

Donation::$totalDonated = Donation::$totalDonated - $this->amount;

Anonymous   
Printed Page 122
2nd code of Clonong in PHP5

Code row 4.
$b = $a->__clone();

must be:

$b = clone($a);

Anonymous   
Printed Page 123
top of page

I'm using PHP 5.2.0.

In function __clone() the line:

$this->weightPerUnit = $that->weightPerUnit

produces the error message:
Notice: Undefined variable: that in ... (local file reference)

However, the following line does appear to work:

$this->weightPerUnit = $this->weightPerUnit

So far, I've not found an explanation for this in any of the standard PHP documentation.

Alex Edwards  Jun 05, 2009 
Printed Page 128
3rd para "This approach can be ....

might "proving a way..." be changed to "providing a way..."

Anonymous   
Printed Page 128
last paragraph

"PHP allows access to any known ancestor class using a <i>class reference</i> operator ... We can rewrite the <i>Triangle</i> class to call the ancestor version of the <i>info()</i> functions directly:
<pre>
class Triangle extends Polygon
{ function info()
{ return Shape::info() . Polygon::info() . "Triangle.";
}
}"
</pre>
True, but you can also do this:
<pre>
class Triangle extends Polygon
{ function info()
{ return Dog::info() . "Triangle.";
}
}
</pre>where
<pre>
class Dog
{ function info()
{ return "Dog.";
}
}
</pre>
In other words, the Triangle class can call the version of info() of the totally unrelated class Dog, not just of its ancestors.

Alex Edwards  Jun 05, 2009 
Printed Page 129
Output of first example

The Shape::info() function returns "Shape." The Polygon::info() function returns "Shape.Polygon." Since Triangle::info() returns Shape::info() plus Polygon::info() plus "Triange.", the comment before the print statment should say:
// prints "Shape.Shape.Polygon.Triangle."
With the change to the Triangle class, I think the Polygon class should have been motified to simpley return "Polygon.", without calling the parent::info() function.

Anonymous   
Printed Page 129
Output of first example

The Shape::info() function returns "Shape." The Polygon::info() function returns "Shape.Polygon." Since Triangle::info() returns Shape::info() plus Polygon::info() plus "Triange.", the comment before the print statment should say:
// prints "Shape.Shape.Polygon.Triangle."
With the change to the Triangle class, I think the Polygon class should have been motified to simpley return "Polygon.", without calling the parent::info() function.

Anonymous  Jul 21, 2008 
Printed Page 131
catch statement in example in middle of page

Missing double-quote at the end of the print statement.

I.e.

print "There was an error: {$x->getMessage()};

should be

print "There was an error: {$x->getMessage()}";

Anonymous   
Printed Page 134
chapter 5--after instalatiion attempting to run wine store.

Not even the Index page will work.

The store conflicts with current php updates the code needs updating.

Catchable fatal error: Object of class winestoreTemplate could not be converted to string in C:wampwwwwda2-winestoreincludescustomHandler.inc on line 44

This also shows up on your online wine store example.

After researching I found out that since php 5.2.5 they have changed how objects are converted to strings which also conflicts with concatenating a "./n" in the code.

Anonymous   
Printed Page 158
GROUP BY statement in final example on page

The GROUP BY statement ends with count(*)>2, but the example output on the next page includes
count(*) values of 2. I.e. the GROUP BY statement should have the ">" replaced with a ">=".

Anonymous   
Printed Page 168
5th para, INSERT statement

When running the INSERT statement:

INSERT INTO wine SET wine_id=1049, wine_name='Curry Hill', year=1996, description='A beautiful
mature wine. Ideal with red meat.';

In the command-line interpretor I get:

ERROR 1364 (HY000): Field 'wine_type' doesn't have a default value

Anonymous   
Printed Page 169
grape_variety table

The authors are seriously misinformed about grape varieties. "Cabernet Sauvignon" is one variety, "Cabernet Franc" is a different variety, "Sauvignon Blanc" is something else; "Pinot Noir" is a variety, "Pinot Gris" is a different variety, and "Pinot Blanc" is yet another variety.

The authors seem to be saying the "Pinot," "Gris," "Noir," "Blanc," and "Sauvignon" are all different varieties of wine grapes, which is not correct.

Although this does not affect the technical information in the book or the validity of the case study, it is a distracting error.

Melinda McBride  Feb 07, 2010 
Printed Page 176
last paragraph

The last paragraph incorrectly refers to non-existant function "mysql_errorno()" rather than the correct "mysql_errno()".

Anonymous   
Printed Page 176
last paragraph

The last paragraph incorrectly refers to non-existant function "mysql_errorno()" rather than the correct "mysql_errno()".

Anonymous  Jul 22, 2008 
Printed Page 184
apache code towards bottom of page

Given Apache httpd.conf change does not match that given in Appendices A-C; it is missing "Satisfy
All".

Anonymous   
Printed Page 191
middle of page

Erroneous use of curly quote in "The value of $_GET["regionName"] is then automatically... "

Anonymous   
Printed Page 198
third paragraph

It states that shellclean() and mysqlclean() are in db.inc. db.inc is shown on page
183 but does not include these functions.

A similar statement is on page 253, center paragraph.
shellclean() is shown on page 200 and mysqlclean() is shown on page 202.

AUTHOR: There are several versions of db.inc. It evolves throughout the book as new
functions and variables are added. The version on the website is the final
version and does contain the functions.

Anonymous   
Printed Page 202
partial paragraph at top

The example at the top of the page specifies a max length of 7 for the value, but the next line shows an 8-byte value. Either the example should be changed to a max length of 8, or else the returned string should be listed as '2001;ca'.

Anonymous   
Printed Page 202
partial paragraph at top

The example at the top of the page specifies a max length of 7 for the value, but the next line shows an 8-byte value. Either the example should be changed to a max length of 8, or else the returned string should be listed as '2001;ca'.

Anonymous  Jul 23, 2008 
Printed Page 210
sample code at bottom of page

I think a line is missing in the SELECT clause. It is selecting odate and idate (followed by a comma which will cause a SQL syntax error), but the print statements are expecting columns named "cust_id" and "order_id", in addition to idate and odate.

Anonymous   
Printed Page 210
sample code at bottom of page

I think a line is missing in the SELECT clause. It is selecting odate and idate (followed by a comma which will cause a SQL syntax error), but the print statements are expecting columns named "cust_id" and "order_id", in addition to idate and odate.

Anonymous  Jul 23, 2008 
Printed Page 211
line above mysql_insert_id heading

The last line of the example is missing a closing square bracket. It should read:
print "There are {$row["custcount"]} customers";
^ is missing

Anonymous  Jul 23, 2008 
Printed Page 212
Last line

reads:

"source; we discuss processing user data later in the chapter."

Actually this was discussed earlier in the chapter p.198-205

so it should read:

"source; we discussed processing user data earlier in the chapter."

Anonymous   
Printed Page 223
first word

The very first word on the page is misspelled. It says "sever" instead of "server".

Anonymous  Jul 25, 2008 
Printed Page 240
Section "Preserving and removing blocks", 1st paragraph, 3rd and 5th sentence

The documentation of the loadTemplatefile() function switches the meaning of the second
and third function parameter. The 3rd sentence says: "The second parameter specifies..."
It should read "The third parameter specifies...". Conversely, the 5th sentence should
say "The second parameter..." instead of "The third parameter..."

Anonymous   
Printed Page 245
3rd and 4th function descriptions

Both the blockExists() and BlockvariableExists() functions are declared here to return an array, but the description says that they return true or false.

Anonymous   
Printed Page 245
3rd and 4th function descriptions

Both the blockExists() and BlockvariableExists() functions are declared here to return an array, but the description says that they return true or false.

Anonymous  Jul 25, 2008 
Printed Page 297
2nd paragraph, 4th line

$_GET["year"] uses an opening double quote just before "year" instead of the standard double prime.

Anonymous   
Printed Page 301
Step #2 near top of page

I believe that

"If the double of the digit is greater than 10 ..."

should read

"If the double of the digit is greater than 9 ..."

Anonymous   
Printed Page 307
5th line from bottom

"Netscape still use the name JavaScript"
should be
"Netscape still uses the name JavaScript"

Anonymous   
Printed Page 362
2nd line from bottom

$_COOKIE["PHPSESSID"] uses an opening double quote just before "PHPSESSID" instead of the standard double prime.

Anonymous   
Printed Page 371
diagram at top of page

The bottom arrow is labeled "201 OK".
It should either be "200 OK" or 201 Created".

Anonymous   
Printed Page 429
Example 13-2, line 37

This might just be me, but I can't example.13-2.php to create a valid PDF file unless I change line
37 from

$doc->ezImage("rabbit.jpg", "", "", "none");

to

@$doc->ezImage("rabbit.jpg", "", "", "none");

The code in the book causes PHP to generate a notice, "<br />
<b>Notice</b>: Undefined variable: temp in <b>/Library/WebServer/Documents/wda/class.ezpdf.php</b>
on line <b>1416</b><br />" at the top of the PDF it creates.

Anonymous   
Printed Page 461
First code line in "Functions" section

There should be a comma after $s.

Anonymous   
Printed Page 486
1/4 and 3/4 down the page

Of the three SELECT statements on the page, the first and third have the first "S" in "SELECT" bolded for no apparent
reason.

Anonymous   
Printed Page 499
First full line

It says, "In the previous chapter, we showed you how to insert data using three
different techniques". I don't see this in the previous chapter, "Advanced Features
of Object-Oriented Programmin in PHP 5". I'm not sure where the three techniques are
shown. And, it would be nice to list what the three techniques are.

Anonymous   
Printed Page 509
First paragraph

The book says that strcmp is case-sensitive. However, as the example in Table 15-2
shows, it is case-insensitive.

Anonymous   
Printed Page 556-559, 565-567
calls to parseCurrentBlock()

parseCurrentBlock() takes no arguments. This is correctly stated on page 246 but calls on the above pages include an argument.

Anonymous  Nov 24, 2008 
Printed Page 580
Line 11 from bottom

The line says, "Retrieve the oldest price", but it is actually retrieving the
minimum price.

Anonymous   
Printed Page 600
Select statement in middle of page

The query groups on wine_id, but sorts on date_added. There can be several records with the same
wine_id, but different date_added values, so it isn't clear which date_added value the query will
return. I tried a little experiment, but couldn't
tell if MySQL will always return a specific record or just returns the first one it
finds when it does the grouping. If the query is actually correct, then the book
should explain this.

Anonymous   
Printed Page 674
Point 4 command for "Starting MySQL"

/usr/local/mysql/bin/safe_mysqld --user=mysql &
should be:
/usr/local/mysql/bin/mysqld_safe --user=mysql &

since there is no safe_mysqld command.

AUTHOR: It depends on what version you use. The instructions are correct for
the versions in the book, but it's true that safe_mysqld became mysqld_safe
so that all mysql binaries/scripts began with the prefix mysql*.

Anonymous   
Printed Page 681
Point 8 command for "Installing PHP"

% ./configure --with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/local/mysql/

The final forward slash '/' causes errors on the configure. It should not be there,
with the correct command being:

% ./configure --with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/local/mysql

Anonymous   
Printed Page 709
Step 3

The unix command:
% pico /etc/http/httpd.conf

should read:
% pico /etc/httpd/httpd.conf

Anonymous   
Printed Page 720
Line 4 from top

"/" should be "./".

Anonymous