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 62
within function drop ( sid )

The following line has an error:

divobj.style.top = aobj.offsetBottom+10;

when this line is commented out, the code works without issue.

Anonymous 
Printed Page 81-92
call to set text

I am a big fan of PHP hacks. However I am having trouble getting the calendar to work.
The problem is that the call to setCalendarText does not seem to be inserting the
text into the $days. Everything else is fine.

This is the class declaration:

class Day
{
function Day ($inmonth, $month, $day, $year)
{
$this->{'month'} = $month;
$this->{'day'} = $day;
$this->{'year'} = $year;
$this->{'month'} = $month;
$this->{'inmonth'} = $inmonth;
$this->{'text'} = '';
}
function get_day() { return $this->{'day'};}
function get_month() { return $this->{'month'};}
function get_year() { return $this->{'year'};}
function get_inmonth() { return $this->{'inmonth'};}
function get_text() { return $this->{'text'};}
function set_text($text){ $this->{'text'}=$text; }
}

Here is the setCalendarText function:

function setCalendarText( $days, $m, $d, $y, $text )
{
foreach( $days as $day)
{
if( $day->get_day() == $d && $day->get_month() == $m && $day->get_year() == $y )
$day->set_text($text);

}
}

Here is the page call:

<div class"calendar_content">
<?php echo ( $d->get_text() ); ?>
</div>

Echoing $this->{'text'} in the function set_text shows the text but it does not get
inserted into the $days and therefore does not appear on the page.

Can you offer any insights?

Anonymous 
Printed Page 88
Some place in code

Hack #25
The last day of previous month is always wrong.

Anonymous 
Printed Page 88
function setCalendarText

I have tried everything and cannot get the text to show in the calendar. And where is
the function number used? I see no call for it.

Anonymous 
Printed Page 90
3rd line from bottom

Previous month ends a day early.
Creating days for previous month needs to subtract 1 from the day value.

It appears that the previous errata for this is incorrect. They state that you need to subtract 1
from ($day - $d) but you need to add 1.
Was (in book): $days[] = new Day(0, $lastmonth + 1, $dimlm - ($day - $d), $lastyear);

Should be:
$days[] = new Day(0, $lastmonth + 1, $dimlm - ($day - $d) + 1, $lastyear);

Anonymous 
Printed Page 90
In 9780596101398.confirmed on website

In the confirmed errata, you have a correction stating:
---------------------------------------------------------
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);
---------------------------------------------------------

In actual fact, you need to add one, not subtract
$days []= new Day(0,$lastmonth+1,$dimlm - ($day - $d) + 1, $lastyear);

Anonymous 
Printed Page 91
16th & 17th line of code

while running this script in a php 5 environmen i encountered the following warnings:

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would
like to pass it by reference, modify the declaration of setCalendarText(). If you would like to
enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI
file. However, future versions may not support this any longer. in C:webrootcityofwpbcalcal.php
on line 127

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would
like to pass it by reference, modify the declaration of setCalendarText(). If you would like to
enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI
file. However, future versions may not support this any longer. in C:webrootcityofwpbcalcal.php
on line 128

The deprecated problem should be taken care of.

Anonymous 
Printed Page 91
4th pocket of code

if ($_GET['month'] ) $month = $_GET['month'];

This section of code won't work when the current month is December, going forward a month. January is represented in 0 in your code. As it is 0 the if statement is evaluated to false, so the line of code will never be executed and January will not be set as the month. It will always be set to the current month that your server thinks that it is.

Anonymous 
Printed Page 151
4th line

require_once( "DB.php" );

This occurs on several pages but there does not appear to be anywhere where the content of that file is listed.

Calum MacLeod 
Printed Page 157
various, including six lines up fro the bottom of page 157; but others as well

RE: Generate CRUD Database Code Hack #37:

I am getting null values for all instances where "<?php echo( $pk ); ?>" is intended to place the
name of the primary key field into the output from gen.php script.

I have gone in circles attempting to reslove the issue, to no avail. The confusion is related to the
issue previously reported in online ERRATA pertaining to page 158 where a literal "id" was used to
reference what ought to be another instance of the "$pk" value.

However, even with that information, I am not yet able to resolve the problem. I believe the solution
may require iterating through the current table[field] array to locate an instance of A PRIMARY-KEY-
FIELD NAME. Thus far, a solution has escaped me. And I don't know whether gen.php will work with
tables that have multiple primary keys defined...

Furthermore, the problem appears to manifest itself elsewhere also, as "gen.php" is placing a "$this-
>" null value at the end of the all the locations where the "$updfields" array is being inserted.

This is probably a simple fix for the author, who will readily recognize where the "ID" and "PK"
references need to be distinguished. Meanwhilie, if you have a solution, I would like to hear about
it ASAP.

Anonymous 
Printed Page 157-60
various as indicated below

Follow up on Hack#37 Issues:

I believe I now have gen.php script working; please review the following feedback:

A. Page 157, 11 lines from the bottom of the page,
It appears the line
$this->id = null;
Should read
$this-><?php echo( $pk ); ?> = null;

B. Instructions should include that line on page 156:
$field['pk'] = ( $attribs['PRIMARY-KEY'] == "true" ) ? 1 : 0;
May need to be modified to match external XML attribute specifications, e.g.:
$field['pk'] = ( $attribs['PRIMARY_KEY'] == "yes" ) ? 1 : 0;

C. Some "best practices" discussion could be included regarding the prerequisite
that every table must contain at least one primary key field. If this is not the case,
then the program needs to handle references where no primary key exists.

D. To my knowledge, sql "views" do not signify primary keys, therefore, gen.php
will not correctly process "sql views" when they are included within the XML schema.

E. Oddly, using Hack #39 to generate XML will not work with Hack #37 because the XML
attributes do not include the "primary key" indicators.
I used another export utility to retrieve the XML schema:
http://www.webcheatsheet.com/php/export_database_schema_xml.php

Anonymous 
Printed Page 157
various, including six lines up fro the bottom of page 157; but others as well

RE: Generate CRUD Database Code Hack #37:

I really like the book; but am getting null values for all instances where "<?php echo( $pk ); ?>" is intended to place the name of the primary key field into the output from gen.php script.

I have gone in circles attempting to reslove the issue; to no avail. The confusion is related to the issue previously reported in online ERRATA pertaining to page 158 where a literal "id" was used to reference what ought to be another instance of the "$pk" value.

However, even with that information, I am not yet able to resolve the problem. I believe the solution may require iterating through the current table[field] array to locate an instance of A PRIMARY-KEY-FIELD NAME. Thus far, a solution has escaped me. And I don't know whether gen.php will work with tables that have multiple primary keys defined...

Furthermore, the problem appears to manifest itself elsewhere also, as "gen.php" is placing a "$this->" null value at the end of the all the locations where the "$updfields" array is being inserted.

This is probably a simple fix for the author, who will readily recognize where the "ID" and "PK" references need to be distinguished. I'll keep trying....

Meanwhilie, if you have a solution, I would like to hear about it ASAP. Thank you.


Anonymous 


"...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