Categories

Core PHP Programming 1/E Errata

These are issues with the first edition that have come up since the book was published. Some of them have been fixed in subsequent printings.

04/19/2000

Tyler Bannister points out that Figure 16-6 uses a timeout value of 3 hours instead of 30 minutes. Use 1800 seconds instead of 10800.

Thanks, Tyler!

02/15/2000

Jay Lepore pointed out that the example for mysql_list_fields wasn’t working.
That’s because it needs to be used with mysql_field_name, mysql_field_len,
mysql_feild_type and mysql_field_flags. Here’s a better example:

<?
	// connect to server 

	$Link = mysql_connect("localhost", "httpd", "");

	// get list of fields 
	$Result = mysql_list_fields("store", "customer", $Link);

	//start HTML table
	print("<TABLE>\n");
	print("<TR>\n");
	print("<TH>Name</TH>\n");
	print("<TH>Type</TH>\n");
	print("<TH>Length</TH>\n");
	print("<TH>Flags</TH>\n");
	print("</TR>\n");

	//loop over each field
	for($i = 0; $i < mysql_num_fields($Result); $i++)
	{
		print("<TR>\n");
	
		print("<TD>" . mysql_field_name($Result, $i) . "</TD>\n");
		print("<TD>" . mysql_field_type($Result, $i) . "</TD>\n");
		print("<TD>" . mysql_field_len($Result, $i) . "</TD>\n");
		print("<TD>" . mysql_field_flags($Result, $i) . "</TD>\n");

		print("</TR>\n");
	}

	//close HTML table
	print("</TABLE>\n");
?>

Thanks, Jay!

12/12/1999

Matt Van Gundy pointed out that the recursion example on page 58 has a weakness
for numbers between -1 and zero that will cause it to go into an infinite loop!
That's what I get for inventing such a contrived example. The fix it to change
this link:

return(checkInteger((-1) * $Number - 1));

to

return(checkInteger((-1) * $Number));

Thanks, Matt!

11/8/1999

Here are a couple of new codes for the date() function. You can get the number of seconds
on the clock with the s code. You can get the timezone with the T code. This is another
tip from Ezra Freedman.

11/3/1999

The mysql_insert_id() function takes one optional argument, the
link identifier. The description of this function doesn't
mention this, and the example mistakenly uses the result identifier.
Here's fixed example.

<?
	// connect to server 
	$mysql_link = mysql_connect("localhost", "httpd", "");

	// select the 'store' database 
	mysql_select_db("store", $mysql_link);

	// insert a row 
	$query = "INSERT INTO customer (name) ";
	$query .= "VALUES('Leon Atkinson') ";
	$mysql_result = mysql_query($query, $mysql_link);

	// get id 
	print("ID is " . mysql_insert_id($mysql_link));
?>

Thanks to Ezra Freedman for letting me know.

10/26/1999

The order of the parameters for implode() are reversed. The prototype
should read

string implode(string delimiter, array data)

Thanks to Paul Kulp for pointing this out.

09/08/1999

The fread() function was left out of the functional reference. It works exactly
like fgets() except for one important difference. The fread() function is binary
safe. It ignores endlines when returning strings.

08/01/1999

The example on page 35 has an error. "$Count = $Count + 1" is not the same as
"$Count += $Count". The correct example should be:

<?
	/*
	** this assignment
	*/
	$Count = $Count + 1;
	
	/*
	** is the same as this assignment
	*/
	$Count += 1;
?>

Thanks to Erico Freitas for pointing this out.

07/14/1999

David Cooper pointed out that there's a error in the example for
mysql_field_name(). Change this line

print(mysql_field_name($index) . "<BR>\n");

with

print(mysql_field_name($mysql_result, $index) . "<BR>\n");

Thanks, David!

06/29/1999

Here's a bunch of issues that Paul DuBois sent me. Wow! Check out the
detail! I've only listed the issues that pertain to content, since some
of them were about fonts or typos:

p342. MySQL isn't exactly "free" in the sense that there are conditions
under which you must license it (e.g., if you sell it or a product
that requires it).

p343. The MySQL website www.tcx.se is now better referred to as
www.mysql.com. (The MySQL manual and other related documentation
made this change recently.)

p346. Description of mysql_db_query: says that a new link will be
created if necessary. This is also true for mysql_query and
mysql_select_db, but the descriptions of the three functions don't
point this out consistently. It's also not clear what parameters
will be used to make the connection (no doubt because the PHP manual
itself is pretty murky on this point!).

p347 Example for mysql_errno. mysql_errno and mysql_error won't actually
return any useful information after a failed connect call. They require
a valid link. A better example might be, say, a mysql_query with an
illegal query followed by mysql_errno/mysql_error calls.

(You can get the error information after a failed connect call, but you
have to have track-errors turned in in php3.ini and you reference
$php_errormsg instead of the MySQL error functions. I think this is goofy,
but that's how it is.)

p350 Description of mysql_fetch_lengths is incorrect. It returns the
actual lengths of the fields in the current row of the result set, I
believe. (Just like the corresponding C API call.)

p358. mysql_insert_id is missing the argument in the function header
(should have "integer result" in the parens).

06/26/1999

On page 71, the second instance of $tempVariable is mis-spelled. Thanks,
Nick Bouton!

06/21/1999

On page 233, Figure 11-1 lists I instead of i. Thanks,
John Keklak!

06/10/1999

On page 388, the call to ora_logon is missing a comma. Change

ora_logon("leon" "secret")

to

ora_logon("leon", "secret")

Many thanks to Ron Sprenkels for catching this error!

06/09/1999

In Chapter 13, a dollar sign crept into the calls to mysql_select_db(). For example,

$mysql_select_db("store", $mysql_link);

should be

mysql_select_db("store", $mysql_link);

Here's a shout out to Brian Wang for pointing it out!

06/01/1999

In Chapter 9, I failed to mention that encrypt() and decrypt()
are from the crypt extension. That means before you use them, you must load
the extension with dl() or inside php3.ini. I also noticed that
the example has a minor error: the password is too short. Here's a fixed example,
with code to load the extention:

<HTML>
<HEAD>
<TITLE>decrypt</TITLE>
</HEAD>
<BODY>
<?
	dl("crypt.dll");

	$message = "this is a plain text message";
	$password = "mysecretpassword";
	$data = encrypt($message, 0, $password);
	print(decrypt($data, 0, $password));
?>
</BODY>
</HTML>

Leave a Reply

Your email address will not be published. Required fields are marked *