Web Database Applications with PHP and MySQL, 2nd Edition by Hugh E. Williams, David Lane The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated April 10, 2008. UNCONFIRMED errors and comments from readers: {7} Last paragraph on p. 7, continuing on p. 8.; The description of "servers" could use a bit of clarification (for some audiences). The concept of the "web server" has, up to this point, been depicted in various figures as a hardware box that looks like a typical PC. This paragraph describes a server as a set of programs, one of which coordinates the others. The paragraph goes on to describe the "starting of new servers" (What? Another hardware box?) and the "killing of unused servers" (How do you "kill" a piece of hardware?). This could be a mystery unless the reader understands the concept that the "the server" is "a set/ collection of intercommunicating processes/programs, i.e., software, that is/are running on one or more computers", and that the controlling/coordinating process has the ability to dynamically create/spawn/give birth to additional processes, and destroy them, in order to share the load. [41] 6th paragraph, 1st edition; Following the text 'It's also common for the else clause to execute a block of statements in brackets ...' It seems to me that the 'true' and 'else' are reversed. i.e., 'if ($var > 5) should echo "Variable is greater than 5" [77] 2nd paragraph; The description of printf states that it will "truncate" floating point numbers. This is wrong. It rounds them. As does the same function in C. This error is repeated on page 79 in example 3-2. The first line will output: "Over 55.72% of statistics are made up." The comment states that the number will be 55.71 because it assumes that the argument 55.719 will be truncated rather than rounded. [81] paragraph 2 (paragraph numbers ignores code listings); Book says: "Both strcmp() and strncmp() take two strings as parameters, str1 and str2, and return 0 if the strings are identical, 1 if str1 is less than str2, and -1 if str1 is greater that (sic) str2." This is incorrect. strcmp() returns -1 if str1 is LESS than str2, and 1 if str1 is GREATER than str2. (Just before the above, the prototype of strcmp shows str1 as the first argument to strcmp, and str2 as the second argument.) {81} 2nd paragraph of section "Comparing Strings"; "Both strcmp( ) and strncmp( ) take two strings as parameters, str1 and str2, and return 0 if the strings are identical, 1 if str1 is less than str2, and -1 if str1 is greater that str2." "1 if str1 is less than str2, and -1 if str1 is greater that str2" is inconsistant with examples below on same page: print strcmp("aardvark", "zebra"); // -1 print strcmp("zebra", "aardvark"); // 1 print strcmp("mouse", "Mouse"); // 1 print strncmp("aardvark", "aardwolf", 5); // -1 Examples are correct and statement is wrong. (90) Sec. 3.3.1.4. Optional and repeating characters; In 3.3.1.4. Optional and repeating characters: ******************************************** $hexString = "x01ff"; // True for strings that start with 'x' followed by at least // one hexadecimal digit $matches = ereg('x[0-9a-fA-F]+$', $hexString); // true ******************************************** This regexp should begin with '^' to match strings that start with 'x'... {98} 4 lines from end; Example gives: $var = strtotime("14/5/1955") The strtotime function takes a US format date, so this should be given as: $var = strtotime("5/14/1955") {119} __destruct function in example 4.6; The destructor uses $donation, but this only exists as a value for the constructor. Hence it creates an "undefined variable" error. Donation::$totalDonated = Donation::$totalDonated - $donation; should be replace with Donation::$totalDonated = Donation::$totalDonated - $this->amount; (122) 2nd code of Clonong in PHP5; Code row 4. $b = $a->__clone(); must be: $b = clone($a); (128) 3rd para "This approach can be ....; might "proving a way..." be changed to "providing a way..." {131} catch statement in example in middle of page; Missing double-quote at the end of the print statement. I.e. print "There was an error: {$x->getMessage()}; should be print "There was an error: {$x->getMessage()}"; {158} GROUP BY statement in final example on page; The GROUP BY statement ends with count(*)>2, but the example output on the next page includes count(*) values of 2. I.e. the GROUP BY statement should have the ">" replaced with a ">=". [168] 5th para, INSERT statement; When running the INSERT statement: INSERT INTO wine SET wine_id=1049, wine_name='Curry Hill', year=1996, description='A beautiful mature wine. Ideal with red meat.'; In the command-line interpretor I get: ERROR 1364 (HY000): Field 'wine_type' doesn't have a default value {184} apache code towards bottom of page; Given Apache httpd.conf change does not match that given in Appendices A-C; it is missing "Satisfy All". {198} third paragraph; It states that shellclean() and mysqlclean() are in db.inc. db.inc is shown on page 183 but does not include these functions. A similar statement is on page 253, center paragraph. shellclean() is shown on page 200 and mysqlclean() is shown on page 202. AUTHOR: There are several versions of db.inc. It evolves throughout the book as new functions and variables are added. The version on the website is the final version and does contain the functions. (212) Last line; reads: "source; we discuss processing user data later in the chapter." Actually this was discussed earlier in the chapter p.198-205 so it should read: "source; we discussed processing user data earlier in the chapter." {240} Section "Preserving and removing blocks", 1st paragraph, 3rd and 5th sentence; The documentation of the loadTemplatefile() function switches the meaning of the second and third function parameter. The 3rd sentence says: "The second parameter specifies..." It should read "The third parameter specifies...". Conversely, the 5th sentence should say "The second parameter..." instead of "The third parameter..." [429] Example 13-2, line 37; This might just be me, but I can't example.13-2.php to create a valid PDF file unless I change line 37 from $doc->ezImage("rabbit.jpg", "", "", "none"); to @$doc->ezImage("rabbit.jpg", "", "", "none"); The code in the book causes PHP to generate a notice, "
Notice: Undefined variable: temp in /Library/WebServer/Documents/wda/class.ezpdf.php on line 1416
" at the top of the PDF it creates. {301} Step #2 near top of page; I believe that "If the double of the digit is greater than 10 ..." should read "If the double of the digit is greater than 9 ..." (461) First code line in "Functions" section; There should be a comma after $s. (499) First full line; It says, "In the previous chapter, we showed you how to insert data using three different techniques". I don't see this in the previous chapter, "Advanced Features of Object-Oriented Programmin in PHP 5". I'm not sure where the three techniques are shown. And, it would be nice to list what the three techniques are. {509} First paragraph; The book says that strcmp is case-sensitive. However, as the example in Table 15-2 shows, it is case-insensitive. (580) Line 11 from bottom; The line says, "Retrieve the oldest price", but it is actually retrieving the minimum price. {600} Select statement in middle of page; The query groups on wine_id, but sorts on date_added. There can be several records with the same wine_id, but different date_added values, so it isn't clear which date_added value the query will return. I tried a little experiment, but couldn't tell if MySQL will always return a specific record or just returns the first one it finds when it does the grouping. If the query is actually correct, then the book should explain this. (674) Point 4 command for "Starting MySQL"; /usr/local/mysql/bin/safe_mysqld --user=mysql & should be: /usr/local/mysql/bin/mysqld_safe --user=mysql & since there is no safe_mysqld command. AUTHOR: It depends on what version you use. The instructions are correct for the versions in the book, but it's true that safe_mysqld became mysqld_safe so that all mysql binaries/scripts began with the prefix mysql*. {681} Point 8 command for "Installing PHP"; % ./configure --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql/ The final forward slash '/' causes errors on the configure. It should not be there, with the correct command being: % ./configure --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql {709} Step 3; The unix command: % pico /etc/http/httpd.conf should read: % pico /etc/httpd/httpd.conf (720) Line 4 from top; "/" should be "./".