Errata

Learning PHP & MySQL

Errata for Learning PHP & 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 Page 11
Paragraph that begins "It's also good practice..."

("Instead of <b>bold<i> italic</i></b>, you should close the code like this: </b></i>.) In other words, you should open and close items at the same level. So, if you open a bold and then italic, you should close the italic before you close the bold."

"<b>bold<i> italic</i></b>", is correct, although I would not use the <i> on the space before "italic"...that's just an editor's thing, <b>bold <i>italic</i></b> is better.

"you should close the code like this: </b></i>" is wrong and conflicting. Close from the inside out. Some browsers care.

Anonymous  Jul 31, 2008 
Printed Page 3
Paragraph that falls under "PHP and MySQL have community support"

"Both tools active communities on the Web...."
Missing verb.

Anonymous  Jul 31, 2008 
Printed Page 16
4th paragraph (step 1)

The position where to download, the name and the FORMAT of the file to download is not updated. Apache
server now is a zip file and not a MSI installer as stated in the book. The procedure is changed.

*Note from author* Although the version has changed slightly, following the instructions still leads to a file called http://www.devlib.org/apache/httpd/binaries/win32/apache_2.2.9-win32-x86-no_ssl-r2.msi.

Anonymous   
Printed Page 33
1st paragraph starts with "6. Verify that ..." (This is in Chapter 2: Installation)

php_mysql.dll should be php_mysli.dll

*Note from author* If using the standalone MySQL Connector you may either use MySQL or MySQLi. If you were to use the MySQLi connector then it would be php_mysqli.dll. Please note that MySQL connectivity, as an extenstion, has been added back into the PHP5 installer as of version 5.2.6 or later.

Anonymous   
Printed Page 57
Example 3-22

Example 3-22 PHP mathematical function usage

<?PHP>...

Needs to be

<?PHP....

Joe Mussi  Apr 23, 2009 
Printed Page 69
Top of the page

the first line under the Associativity heading, says "All operators process their operators in a certain direction", operators being used twice.

I think it should be "All operators process their OPERANDS in a certain direction." but maybe not in CAPS ;)

Anonymous  Nov 01, 2008 
Printed Page 82
Bottom Paragraph

Code in the book:

echo "100/$counter ",100/$counter,"<br />";

The problem with this code is that since echo does not accept more than one string, you must concatenate the string using periods and not by using commas.

Drupal Meister  Jul 05, 2009 
Printed Page 91
Example 5-5

Example 5-5 contains the line:
echo ("Now do the same with the echo parameter set to FALSE.<br>");

The parameter is called the 'each' parameter, so the line should be:
echo ("Now do the same with the each parameter set to FALSE.<br>");

This error is replicated in the Example output, immediately below the example.

Anonymous  Nov 01, 2008 
Printed Page 97
Bottom Paragraph

The function used to instantiate a class is __construct() and not __constructor()

Drupal Meister  Jul 05, 2009 
PDF Page 107
Last paragraph

Current text says "Numeric arrays use numbers as their indexes, while associative arrays use stings." The last word should be "strings".

Anonymous  Aug 18, 2008 
Printed Page 117
Bottom Paragraph

There is no PHP function expand(), instead the same extract() mentioned earlier is used with some additional parameters.

Drupal Meister  Jul 05, 2009 
Printed Page 126
5th paragraph

The line reads "Assuming you've done everything correctly, you'll be set up with new data, and it will be selected for use."

I'm not sure what new 'data' it is referring to since we've just created an empty database.

I think the line should be "Assuming you've done everything correctly, you'll be set up with A new dataBASE, and it will be selected for use."

Anonymous  Nov 04, 2008 
Printed Page 133
3rd paragraph, beginning "Example 7-1"

The line reads, "Example 7-1 creates the book table using the data types from Table 7-8."

There is no Table 7-8.

Anonymous   
Printed Page 138
3rd last paragraph

the given syntax of the select statement is: SELECT columns FROM tables [WHERE CLAUSE]; [ORDER BY CLAUSE];

the semicolon after the WHERE clause should be removed: SELECT columns FROM tables [WHERE CLAUSE] [ORDER BY CLAUSE];

Anonymous  Nov 05, 2008 
PDF Page 140
Last two lines

FROM:
INSERT INTO `purchases` VALUES (1, 'mdavis', 2, '2005-11-26 17:04:29');
INSERT INTO `purchases` VALUES (2, 'mdavis', 1, '2005-11-26 17:05:58');

TO:
INSERT INTO purchases VALUES (1, 'mdavis', 2, '2005-11-26 17:04:29');
INSERT INTO purchases VALUES (2, 'mdavis', 1, '2005-11-26 17:05:58');

Don't need quotes around purchases.

Anonymous  Nov 16, 2009 
Printed Page 141
1st paragraph

the first paragraph of page 141 reads "To create a query that lists the purchases, author, and pages, enter the following SELECT statement:

SELECT books.*, author FROM books, authors WHERE books.title_id = authors.title_id;"

well this query has nothing to do with purchases, or the new purchases table that was just created.

the language before the query should be changed to properly describe the query, or the query its self should make use of the purchases table.



side note: also on the previous page it says to get in the habit of referencing columns as TABLE.COLUMN, but then the author column in the query noted above doesn't mention the TABLE. for consistency it should be use as authors.author .

Anonymous  Nov 05, 2008 
PDF Page 159
First paragraph

The second sentence of the first paragraph reads "Notice that two % signs were used to surround the b, "&b&"."

The percentage signs have been replaced by ampersands in the quotes, but they should still be percentage signs.

Anonymous  Aug 22, 2008 
Printed Page 184
Bottom

In the book you write that extension_dir = "C:/PHP/ext/" would change the extension to inclue the directory to C:/php, while it would actually include the C:/php/ext

Drupal Meister  Jul 08, 2009 
Printed Page 192
Throughout

The book uses the Pear module "DB." The examples provided didn't work for me in PHP 5; a little research
showed that DB had been deprecated about two years ago in favor of MDB2, which contains DB's feature
set. Switching the language references to MDB2 made the examples functional again.

Anonymous   
Printed Page 201
Example 10-2 code

The code shown produces the PHP error

Undefined Index: .../simple.php on line 7 (the line where $search is defined).

Apparently, $_GET["search"] is empty at this point (I guess that makes sense) and not having a value kicks out the error. I've seen methods of squelching the error (via the @ sign and configing php.ini), but that doesn't seem like a good solution at all.

The code still works otherwise.

Anonymous  Dec 01, 2008 
Printed Page 211
Duplicate code

Example 10-6 and Example 10-7 are the same code. 10-7 should be code to validate text, and not a specific set of options.

Drupal Meister  Jul 08, 2009 
Printed Page 213
Example 10-9

Has anyone got this example 10-9 to work properly???
If anyone has had success without modifying the code please let me know. I have been through it line by line without but still have not achieved any real success. I would like to know if it's me or the program.

Anonymous  Jun 13, 2011 
Other Digital Version 214
line number 46

echo 'selected="selected"';

should be:

echo ' selected="selected"';

a space is needed between ' and selected

error is in the book and in the on-line source code.

With out the space, the start tme zone is left out of the select box

Easy Surf  Jun 13, 2009 
Printed Page 216
In the middle

In the code, you are pulling building a table with three columns: Title, Author and Pages. But when you fetch the row you are displaying row[1] row[3] and row[2] respectively, which correspond to Pages, Author and author_id, definitely what we wanted.

Drupal Meister  Jul 08, 2009 
Printed Page 220
1st paragraph, example 10-11

Code for myapp/smarty.php as printed does not work, I have found that the following amended version works:-

<?php
// Use the absolute path for Smarty.class.php
require('c:\xampp\htdocs\Smarty\libs\Smarty.class.php');
$base_path = dirname(__FILE__);
$smarty = new Smarty();
$smarty->template_dir = $base_path.'/smarty/templates';
$smarty->compile_dir = $base_path.'/smarty/templates_c';
$smarty->cache_dir = $base_path.'/smarty/cache';
$smarty->config_dir = $base_path.'/smarty/config';
?>

PeterHe  Feb 03, 2009 
Printed Page 220
Page 220 Example 10-11

Apart from errors already spotted I cannot get this piece of code to work.
Unless there was a structural change to PHP ini file the
$base_path= basename(dirname( __FILE__));
only returns or searches for items in the 'myapp' folder, it prefixes the 'Smarty' folder and goes no further.

I would like to know if anybody has had a successful result with it?

Kevin Harbird  Sep 28, 2011 
Printed Page 229
Bottom Paragraph

Last paragraph on page says that sprintf works exactly as print, while you actually need to say that it works exactly like printf and not just print.

Drupal Meister  Jul 08, 2009 
249
Ex 11-29

To get the output as displayed in figure 11-23, the <pre> tags should be placed within the while statement:

<?php

exec(escapeshellcmd("df"),$output_lines,$return_value);
echo ("Command returned a value of $return_value.");
foreach ($output_lines as $output) {
echo "<pre>";
echo "$output";
echo "</pre>";
}

?>

Otherwise some browsers will display the result all on one line.

Anonymous  May 18, 2009 
249
ex 11-29

Or the pre tags can be maintained as they are, and a new line added after $output thus:

echo "$output\n";

Anonymous  May 18, 2009 
Printed Page 379
bottom of page;

In Solution to Question 4-13, the loop modification expression contains the HTML entity version(&#8722;) of the minus signs (-).

$num&#8722;&#8722; should be $num--

Anonymous  Nov 01, 2008 
PDF Page 379
Solution to question 4-8

Question 4-8 states "What type of operand is an Array Index?"

The answer should be integer or string. An array cannot be used for an Array Index.

Please check discussion on this forum thread, particularly, comment 3, which states "... an array key [or index] cannot be an array."

http://forums.devshed.com/showpost.php?p=2857226&postcount=3

Anonymous  Feb 23, 2013 
Printed Page 381
top of the page

the second part to solution to Question 6-2 is missing a single quote after January.

the answer reads: "array('January,'February','March', ..."

it should be: "array('January','February','March', ..."

Anonymous  Nov 04, 2008