Errata

Programming PHP

Errata for Programming PHP

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 11
Example 1-3

<form action="<?php $PHP_SELF;?>" method="post">

NOW READS:
<form action="<?php echo $PHP_SELF;?>" method="post">

Anonymous    Apr 01, 2004
Printed
Page 30
last example under 'Variables' subsection

The output of this example NOW READS 'Yes!'

Anonymous    Apr 01, 2004
Printed
Page 78
under "Formatting a date"

printf('%02d/%02d/%04y', $month, $day, $year);

NOW READS:
printf('%02d/%02d/%04d', $month, $day, $year);

Anonymous    Apr 01, 2004
Printed
Page 88
Source Code Example for comparison of the Metaphone and Soundex algorithms

...
print "soundex: $known sounds $query<br>";
...
print "metaphone: $known sounds $query<br>";

NOW READS:
...
print "soundex: $known sounds like $query<br>";
...
print "metaphone: $known sounds like $query<br>";

Anonymous    Apr 01, 2004
Printed
Page 94
Source Code Example for the last Occurence of a Multicharacter String

In the source code line
$pos = strpos(strrev-($long), strrev($to_find));

NOW READS:
$pos = strpos(strrev($long), strrev($to_find));

Anonymous    Apr 01, 2004
Printed
Page 102
Example 4-1, (about 1/4 of way up the page from bottom):

$theAdder = (int) $inCardNumber{$i};

NOW READS:
$theAdder = (int) $inCardNumber[$i];

Anonymous    Apr 01, 2004
Printed
Page 111
first set of examples

preg_match('/y(.*)e$/', Sylvie', $m);

NOW READS:
preg_match('/y(.*)e$/', 'Sylvie', $m);

Anonymous    Nov 01, 2004
Printed
Page 112
Example 4-2,

<form action="<?php $PHP_SELF ?>"method="POST">
URL:<input type="text" name="url" value="<?php $url ?>"/><br>

NOW READS:
<form action="<?= $PHP_SELF ?>"method="POST">
URL:<input type="text" name="url" value="<?= $url ?>"/><br>

Anonymous    Apr 01, 2004
Printed
Page 112
Example 4-2, last three lines of code

NOW READ:
}
}
?>

Anonymous    Apr 01, 2004
Printed
Page 164
Example 7-2

$chunk = substr($word, $i*3, 3);

NOW READS:
$chunk = substr($word, $i*$number, $number);

Anonymous    Apr 01, 2004
Printed
Page 172
code snippet at bottom of page

if (is_uploaded_file($_FILES['toProcess']['tmp_name']) {

NOW READS:
if (is_uploaded_file($_FILES['toProcess']['tmp_name'])) {

Anonymous    Nov 01, 2004
Printed
Page 188
Last example on the page

if ($_SERVER{'HTTPS'] !== 'on') {
die("Must be a secure connection");
}

NOW READS:
if ($_SERVER['HTTPS'] !== 'on') {
die("Must be a secure connection");
}

Anonymous    Apr 01, 2004
Printed
Page 199
Shortcuts section

$row = $db->getRow(SQL [, values]]);

NOW READS:
$row = $db->getRow(SQL [, values]);


Anonymous    Apr 01, 2004
Printed
Page 207
Code snippet at top of page

Previously, there is no closing </form> tag in the included sample HTML.
It HAS BEEN ADDED to the code sample, between the 'submit' input line and the closing /body tag, so that the
last four lines of the code NOW READ:

<input type="submit" name="submit" value="Add Catergory">
</form>
</body>
</html>

Anonymous    Nov 01, 2005
Printed
Page 259
example 10-14

pdf_add_note($p,100,650,200,750,"This is a test annotation.","Testing","note",0);

NOW READS:
pdf_add_note($p,100,650,200,750,"This is a test annotation.","Testing","note",1);

Anonymous    Apr 01, 2004
Printed
Page 280
Example 11-14.

exho

NOW READS:
echo

Anonymous    Apr 01, 2004
Printed
Page 372
Example 15-5

As previously printed, there were problems with the code (missing quotation marks,
etc.) It is corrected in the examples file on the O'Reilly web and
FTP sites. Use 15-5.php from there.

The correct code NOW READS:

<html>
<head>
<title>ODBC Transaction Management</title>
</head>
<body>
<h1>Phone List</h1>

<?php
$dd = odbc_connect('PhoneListDSN','user','password');
// disable autocommit if we're confirming
if ($submit == "Add Listing") {
$start_trans = odbc_autocommit($dd,0);
}

//insert if we've got values submitted
if ($submit == "Add Listing" || $submit == "Confirm") {
$sql = "insert into phone_list ([extension],[name])";
$sql .= "values ('$ext_num','$add_name')";
$result = odbc_exec($dd,$sql);
}
?>

<form method="post" action="phone_trans.php">
<table>
<tr><th bgcolor="#EEEEEE">Extension</th>
<th bgcolor="#EEEEEE">Name</th>
</tr>

<?php
// build table of extension and name values
$result = odbc_exec($dd,"select * from phone_list");
$cols = array();
$row = odbc_fetch_into($result,$cols);
while ($row) {
if ($cols[0] === $ext_num && $submit != "Confirm") {
?>
<tr><td bgcolor="#DDFFFF"><?= $cols[0] ?></td>
<td bgcolor="#DDFFFF"><?= $cols[1] ?></td></tr>

<?php
} else {
print("<tr><td>$cols[0]</td><td>$cols[1]</td></tr>
");
}
$row = odbc_fetch_into($result,$cols);
}

// if we're confirming,make hidden fields to carry state over
// and submit with the "Confirm"button
if ($submit == "Add Listing") {
?>

</table>
<br>
<input type="hidden" name="ext_num" value="<?= $ext_num ?>">
<input type="hidden" name="add_name" value="<?= $add_name ?>">
<input type="submit" name="submit" value="Confirm">
<input type="submit" name="submit" value="Cancel">

<?php
} else {
//if we're not confirming, show fields for new values
?>
<tr><td><input type="text" name="ext_num" size="8" maxlength="4"></td>
<br>
<td><input type="text" name="add_name" size="40" maxlength="40"></td>
<br>
</tr>
<br>
</table>
<br>
<input type="submit" name="submit" value="Add Listing">
<br>
<?php
}
?>
</form>
</body>
</html>

Anonymous    Nov 01, 2004
Printed
Page 384
assert() description

"If assertion is true,..." should read
"If assertion is false,..." instead.

Anonymous   
Printed
Page 384
atan2() description

"returns the arctangent of x and y" should be
"returns the arctangent of y/x" instead.

Anonymous   
Printed
Page 391

The table previouslylisted two different values for "I". The first of those two NOW APPEARS as a lower-case "i".

Anonymous    Apr 01, 2004
Printed
Page 392
first para

z Day of the year from "1" through "365"

NOW READS:
z Day of the year from "0" through "365"

Anonymous    Nov 01, 2005
Printed
Page 412
hebrevc function signature

The function signature is "hebrev" but it should be "hebrevc".

Anonymous   
Printed
Page 414
2nd paragraph

string implode(array strings, string separator)

NOW READS:
string implode(string separator, array strings)

Anonymous    Apr 01, 2004
Printed
Page 441
sin function description

"Returns the arc sine of value" should be
"Returns the sine of value".

Anonymous   
Printed
Page 453
unlink function signature

"int unlink(string path)" should be
"bool unlink(string path)".

Anonymous