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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "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



Version Location Description Submitted By Corrected
Printed Page 2
Last paragraph

http.conf should be httpd.conf.

Anonymous  Aug 2007
Printed Page 11
Last line

"% mysql --user=root --password=passwordbtest < books.sql"
should be:
"% mysql --user=root --password=password btest < books.sql"

Anonymous  Aug 2007
Printed Page 24-25
Examples 2-5 and 2-6

All the <? should be <?php

Anonymous  Aug 2007
Printed Page 26-28
Examples 2-7 & 2-8

All the <? tags should be <?php.

Anonymous  Aug 2007
Printed Page 36
Example 2-14

bgcolor="#aaa"
should be
bgcolor="#aaaaaa"

Anonymous  Aug 2007
Printed Page 36-38
Examples 2-14 & 2-15

All the <? tags should be <?php.

Anonymous  Aug 2007
Printed Page 39
Example 2-16

The function "placegraphic" has a hardcoded argument in the function
call "getimagesize".
getimagesize (rss.png)
should be
getimagesize( $file )

Anonymous  Aug 2007
Printed Page 41
Example 2-17

--==Multipart_Boundary_<?php echo($random_hash); ?>
should be
--==Multipart_Boundary_<?php echo("$random_hash
"); ?>
, otherwise MIME structure will be broken.

Anonymous  Aug 2007
Printed Page 51
Example 3-4

The order of the <body> and <html> tags should be reversed.
Likewise with the order of the </html> and </body> tags.

Anonymous  Aug 2007
Printed Page 59
bottom 3rd of page

Second example starting with start_section("two","Report part two")
using a hidden table within <div> does not work. Text "This is a table of numbers and such:"
displays when spinner is clicked but not table of data.

This has been updated on the code in the download.

Anonymous 
Other Digital Version 61

For hack 16 it should be noted that:
The startlink function fails to increment nextid. It now reads:

function start_link( $text )
{
global $nextid;
$nextid++;

Anonymous  Jul 2008
Printed Page 61

For hack 16 it should be noted that:
The startlink function fails to increment nextid. It now reads:

function start_link( $text )
{
global $nextid;
$nextid++;

Anonymous  Aug 2008
Printed Page 62
Inside the javascript function drop(), lines 3-4

Lines 3 and 4 in the function drop():

divobj.style.top = aobj.offsetBottom+10;
divobj.style.left = aobj.offsetLeft+10;
should be:
divobj.style.top = (aobj.offsetBottom+10)+"px";
divobj.style.left = (aobj.offsetLeft+10)+"px";

Anonymous  Aug 2007
Printed Page 64
Example 3-8; the table tag has a misspelled attribute

cellspaceing="0"
should be:
cellspacing="0"

Anonymous  Aug 2007
Printed Page 72
First sentence of "Running the Hack"

"...clock.php to your server and navigate to the it..."
should be:
"...clock.php to your server and navigate to it..."

Anonymous  Aug 2007
Printed Page 85
1st paragraph

flikr
should be
flickr

Anonymous  Aug 2007
Printed Page 88
Author note about Hack 25

the PHP 5 interpreter needs to be installed with the calendar option for this hack to work, or that
if that is not done the php.net site contains code that can be used as an alternative.


Anonymous 
Printed Page 88-92
cal.php errors

Page 90:
First occurance of cal_days_in_month() should use month with a one base.

<is>
$dimlm = cal_days_in_month(CAL_GREGORIAN,$lastmonth, $lastyear)

<should be>
$dimlm = cal_days_in_month(CAL_GREGORIAN,$lastmonth + 1, $lastyear)

Page 90:
Previous month ends a day early.
Creating days for previous month needs to subtract 1 from the day value.
<is>
$days []= new Day(0,$lastmonth+1,$dimlm - ($day -$d), $lastyear);
<should be>
$days []= new Day(0,$lastmonth+1,$dimlm - ($day - $d) - 1, $lastyear);

Page 91:
Testing if month/year are set in URL should use isset($_GET[..]) instead of
if($_GET[...]) otherwise January never shows up in the calendar.

Anonymous  Aug 2007
Printed Page 91
Third line of code

$nexmonth should be $nextmonth

Anonymous  Aug 2007
Printed Page 102
Table-generating code at the bottom half of the page

The looping construct that creates the rows and columns of the table will output
'bad' HTML depending on the number of images in the pics/ directory.

If pics/ contains 1-4 images, then the table is well-formed (only a single row with
1-4 columns.

If pics/ contains exactly 5 images (or a multiple of 5 images), then the well-formed
table rows will be followed by a row with no td elements ("<tr></tr>"), and the
resulting HTML will fail validation (ie. http://validator.w3.org/)

For any other number of images, the last row of the table will be short 1-4 td
elements (even though the resulting HTML will pass validation).

Anonymous 
Other Digital Version 102, 103
Second Paragragh

The author uses the imagecopyresized() function to make image thumbnails, but in
practice this results in terrible-looking images. Switching to the function
imagecopyresampled(), takes the same arguments and produces a much better looking
image. Side by side, the difference between the functions is quite astounding,
especially when looking at an image that you only cut the dimensions in half.

Replaced imagecopyresized with imagecopyresampled.

Anonymous  Jul 2008
Printed Page 102, 103
Second Paragragh

The author uses the imagecopyresized() function to make image thumbnails, but in
practice this results in terrible-looking images. Switching to the function
imagecopyresampled(), takes the same arguments and produces a much better looking
image. Side by side, the difference between the functions is quite astounding,
especially when looking at an image that you only cut the dimensions in half.

Replaced imagecopyresized with imagecopyresampled.

Anonymous  Aug 2008
Printed Page 154
First and second full paragraphs on the page

"New Name" in the explanatory text should not have the question marks on either side of it (ie. "?New Name?").

Anonymous  Aug 2007
Printed Page 195, 201
Figure 5-17 on page 195; Figure 5-19 on page 201

Figures 5-17 and 5-19 should be swapped.

Anonymous 
Printed Page 225
Last line of code

'invoked with with...'
should be
"invoked with..."

Anonymous  Aug 2007
Printed Page 231
Figure 6-9, 2nd (lower) text label on right (response to Second submit)

Change "Accepted" to "Declined because of duplicated ID"

Anonymous 
Other Digital Version 233
3rd line in "Running the Hack"

"mydb" is incorrect since "transtest" is used in trans.php.

'mydb' has been changed to 'transtest'


Anonymous  Jul 2008
Printed Page 233
3rd line in "Running the Hack"

"mydb" is incorrect since "transtest" is used in trans.php.

'mydb' has been changed to 'transtest'


Anonymous  Aug 2008
Other Digital Version 239
Example 6-18. The logout handler

the code now reads:

<?php
session_start();
$_SESSION = array();
session_destroy();
header( "Location: index.php" );
?>

Anonymous  Jul 2008
Printed Page 239
Example 6-18. The logout handler

the code now reads:

<?php
session_start();
$_SESSION = array();
session_destroy();
header( "Location: index.php" );
?>

Anonymous  Aug 2008
Printed Page 240
3rd paragraph from the bottom

"with the 3 value set to 1"
should be:
"with the value for 'bad' set to 1."

Anonymous  Aug 2007
Other Digital Version 247, 249
Last paragraph in p.247 and 1st paragraph in p.249

management.php now reads manage.php.

Anonymous  Jul 2008
Printed Page 247, 249
Last paragraph in p.247 and 1st paragraph in p.249

management.php now reads manage.php.

Anonymous  Aug 2008
Printed Page 251
Last sentence

"...handled by PHP in the MDB() function..." should be
"...handled by PHP in the MD5() function..."

Anonymous  Aug 2007
Printed Page 256
Figures 6-25 and 6-26 should be swapped.

Anonymous 
Printed Page 261
Last paragraph

"can still link directly to articles by referencing the redirection page and supplying the exact URL..."
should be
"can still link directly to articles by supplying the exact URL"

Anonymous  Aug 2007
Printed Page 262
example code

example code not included in the code section. Need to add code to the
downloads in a new directory called 'hack62' or something similar.

Anonymous 
Printed Page 272
Example 6-41

the code line $ip = "64.246.30.37"
is just for debug and should be removed.

Anonymous  Aug 2007
Printed Page 272
Example 6-41

require_once("cache/lite.php"); is unnecessary.

$geo->getAddress($ip); is missing after constructor of Net_Geo.

Anonymous  Aug 2007
Other Digital Version 272
Sampe code for using Net_Get()

After

$geo = new Net_Geo();

added the line:

$res = $geo->getRecord($ip);


Anonymous  Jul 2008
Printed Page 272
Sampe code for using Net_Get()

After

$geo = new Net_Geo();

added the line:

$res = $geo->getRecord($ip);


Anonymous  Aug 2008
Printed Page 274
Example 6-43

code line beginning "$first= ..."
should be:
$first= $card['N'][0]['value'][1][0]
and the code line beginning "$last= ..."
should be:
$last= should be $card['N'][0]['value'][0][0]

Anonymous  Aug 2007
Printed Page 281
2nd line from the bottom

Insert </td> into its own line before </tr>

Anonymous  Aug 2007
Printed Page 283
Figure 6-39

Remove "Checkout" link under Shopping Cart

Anonymous 
Printed Page 308
Figure 7-7

TanleCreator and TanleCreatorImp
should be
TableCreator and TableCreatorImp
respectively.

Anonymous 
Printed Page 310
Figure 7-8

In the DocumentURLHandler class diagram,
"ImageURLHandler" should be "DocumentURLHandler"

Anonymous 
Printed Page 312
Example 7-10

StoryURLHandler should be DocumentURLHandler

Anonymous  Aug 2007
Printed Page 328
Example 7-18

call_user_func( array( $vis, "visitRecord" ), $r );

should be:

$vis->visitRecord( $r );

Anonymous  Aug 2007
Printed Page 353
Second sentence in paragraph following the push-pin note

"docs/index.html"
should be
"doc/index.html"

Anonymous  Aug 2007
Printed Page 370
In Handler_message_normal(), "if" clause is unnecessary.

Anonymous  Aug 2007
Printed Page 372
In NOAA(), $PERSONAL and $NOAA must be specified as "global".

The $PERSONAL and $NOAA variables should be added to the global
line at the top of the function.

Anonymous  Aug 2007
Printed Page 387
2nd paragraph

"...index.phpfile..." should be
"...index.php file"

Anonymous  Aug 2007
Other Digital Version 407
Just below middle of the page, in the "foreach ($images as $img)" loop

The last line of the loop code looks like:

img: "<?php echo ($img['img']) ?>" },

The "," at the end causes a web browser to stop printing icons
after the first iteration. The comma has been removed and now results in the correct code execution.

Note that the download code from the O'Reilly site dated
05-Dec-2006 also has this bug in it. Removing
this comma verified proper functionality.

Anonymous  Jul 2008
Printed Page 407
Just below middle of the page, in the "foreach ($images as $img)" loop

The last line of the loop code looks like:

img: "<?php echo ($img['img']) ?>" },

The "," at the end causes a web browser to stop printing icons
after the first iteration. The comma has been removed and now results in the correct code execution.

Note that the download code from the O'Reilly site dated
05-Dec-2006 also has this bug in it. Removing
this comma verified proper functionality.

Anonymous  Aug 2008


"...PHP Hacks is a worthy title that offers explanations and source code for many valuable site-enhancing applications, testing and code generation techniques, and critical e-commerce safeguards."
--Michael J. Ross, Web Developer, Slashdot.org