“PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” (4th Edition) Errata

Unfortunately, despite the best efforts of myself, the technical editor, the copy editor, the line editor, the proofreader, and despite the multiple revisions, errors still occur. This page lists all the errors found in the book since it went to print.

Note: errors are corrected in subsequent printings and therefore your particular copy may not contain all of the following. You may also be experiencing problems not caused by a mistake in the book. If so, you may find the solution to your problem by using the book’s corresponding forum. Significant changes in the technology will be addressed there and you can also find problems and solutions encountered by other readers.

Known Errors in the Book:

Chapter Page # Description Date Added
Chapter 3: Creating Dynamic Web Sites 107 The second line of code under Step 3, and line 30 of Script 3.10 on page 106, should use multiplication, not division: $dollars = $gallons * $ppg;. October 9, 2011
Chapter 6: Database Design 193 Step 6 should suggest that you repeat Steps 3-5. April 5, 2012
Chapter 7: Advanced SQL and MySQL 205 The first sentence of the third paragraph should say “This join is selecting two columns…”. October 9, 2011
Chapter 7: Advanced SQL and MySQL 210 The query in Step 3 is missing the % before the “Y” (as in the figure). This error is also repeated in the final tip on page 211. January 2, 2013
Chapter 9: Using PHP with MySQL 277 The code in Step 8, which assigns the query to the $q variable is missing its terminating double quotation mark. The corresponding code in Script 9.3 is correct. February 16, 2012
Chapter 10: Common Programming Techniques 320 In the first paragraph, it should say “the first ten records—0 through 9—should be retrieved”. February 16, 2012
Chapter 11: Web Application Development 334 The code in Step 6 should end with a closing PHP tag. January 2, 2013
Chapter 11: Web Application Development 354 The code in Step 8 is missing the closing </li>. January 2, 2013
Chapter 11: Web Application Development 360 The code in Step 9 is missing the readfile() line included in the corresponding script. January 2, 2013
Chapter 12: Cookies and Sessions 389 On line 19 of Script 12.8, the opening [ is missing after $data. The corresponding code in Step 2 is correct. March 14, 2012
Chapter 13: Security Methods 403 The second sentence at the top of the right-hand column should identify Chapter 14 as “Perl-Compatible Regular Expressions”. June 13, 2012
Chapter 13: Security Methods 405 The parenthetical near the end of the first paragraph should say “i.e., $v was found in $value”. August 28, 2012
Chapter 13: Security Methods 405 On line 58 of Script 13.1, the $scrubbed array should be reset instead of $_POST, as this new array is what the form will use. May 1, 2012
Chapter 14: Perl-Compatible Regular Expressions 450 The first line of the second paragraph should begin “Of these modifiers,” January 2, 2013
Chapter 16: An OOP Primer 514 On lines 79-80 of Script 16.5, the form elements should be named just “start” and “end”. The code in the corresponding step is correct. January 2, 2013
Chapter 18: Example—User Registration 563 At the end of Script 18.2, the phrase “paste code here” should not be there. Ugh. December 8, 2011
Chapter 18: Example—User Registration 586 The code in Step 2 should refer to $_GET[‘x’] not $trimmed[’email’] (that’s what I get for copying and pasting). The code in the corresponding script is correct. March 3, 2012
Chapter 18: Example—User Registration 598 Figure E is incorrect. January 8, 2012
Chapter 19: Example—E-Commerce 621 On line 138 of Script 19.2, the two references to $_POST[‘existing’] should be to $_POST[‘artist’]. This also applies to the code in Step 15 on page 627. December 8, 2011
Chapter 19: Example—E-Commerce 635 On line 35 of Script 19.6, the closing </a> is missing. This also applies to the code in Step 5 on page 636. January 2, 2013

70 responses to “PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” (4th Edition) Errata

  1. On P. 205 it says “This join is selecting three columns from the messages table”, but isn’t it only selecting two? message_id and subject?

  2. On page 106, in the calculate_trip_cost function, the calculation on line 30 is:
    $dollars = $gallons/$ppg;
    I think it should be:
    $dollars = $gallons * $ppg;

    • Jack (Peters),

      You’re right. They should add this to the “Known Errors”.

      • I guess the same error also appears a little later, after the code block…

        Larry lists step 3 as:

        $gallons = $miles/$mpg;
        $dollars = $gallons/$ppg; <– Again, should read "$dollars = $gallons * $ppg";
        return number_format($dollars, 2);
        } // End of calculate_trip_cost( ) function.

        (Wish I could give a page # for everyone to reference. I have the Kindle version and the only reference I have is "17% Location 3748 of 22878".)


      • Sorry about that. I’ve added it.

  3. I believe there is an error on page 403, top of the left column where the mail function is listed. The comma shown between the left square bracket and the word as ( [,header ]) is misplaced and should be after the word body. … body, [ header ]

    • Thanks for the suggestion, but that’s not an error. That syntax is saying that the header is optional, which is what the square brackets indicate. But, if the header is present, it must be preceded by a comma. No header, no comma. Hence, the comma goes within the square bracket, too.

  4. I think I found more errors.

    Page #563. At the end of the scrtip line 38, you have “paste code here”. I don’t think that should be there.
    Page #621. On script line 138. You have 2 instances of if (isset ($_POST[‘existing’] …however ‘existing’ should rename to ‘artists’ since that is what you are calling the pull-down.

    Thank you.

  5. On page 598 (chapter 18), screen E is incorrect – it shows the login form rather than the reset password form,!

  6. Hello Larry,

    Are you going to add these errors to you column table above?

    Thank you.

  7. I think I noticed a few errors. Larry, please confirm:

    Page 64: “…$_POST[‘interests’][0] storing the value of the first checked box (e.g., Movies)…”
    According to the HTML above this excerpt, $_POST[‘interests’][0] should point to Music, [1] to Movies, etc.

    Page 277: For step 8, the string being assigned to $q is missing an end quote.

    Page 284: Not necessarily an error, but for the first two tips, I think it’s confusing if you don’t provide the argument $r for both the mysqli_fetch_row() and mysqli_fetch_assoc() functions.

    Page 320: “Upon initially calling the script, the first ten records–0 through 10–should be retrieved…”
    Shouldn’t this be “0 through 9″?

    Thanks for your time, Larry.

    • Thanks, HartleySan. The first thing you mentioned isn’t an error, though. $_POST[‘interests’][0] will store the first CHECKED box, regardless of what is actually the first box. I’ve added the other two errors above.

  8. On p586, step 2, you have
    if (isset($_GET[‘x’], $_GET[‘y’]) && filter_var($trimmed[’email’], FILTER_VALIDATE_EMAIL)…
    In the script box on the same page you have (line 9)
    if (isset($_GET[‘x’], $_GET[‘y’]) && filter_var($_GET[‘x’], FILTER_VALIDATE_EMAIL)…

  9. Hello Larry,
    On page 389. Only on the script part of the code on line 19 there is a bracket missing.
    You have: $_SESSION[‘user_id’] = $data’user_id’];
    It should be: $_SESSION[‘user_id’] = $data[‘user_id’];

    Thank you.

  10. Krystal Balduc March 29, 2012 at 7:48 pm

    Hi Larry,

    Should page 193 step 6 read “Repeat Steps 3 through 5 to populate the database” rather than instructing to repeat Steps 1-3?

    Cheers, Krystal

  11. Hi Larry,

    I think I’ve spotted a small oversight on page 405. You change the “sticky form” code on each input of the form to use the $scrubbed array, without changing the code that clears the array if the email is sent successfully.

    I think lines 57 and 58 of script 13.1 should be as follows (although I’m not entirely certain if unset is the best thing to use here?).

    // Clear $scrubbed array (so the form isn’t sticky)

    P.s. the book’s proving to be a great help, thanks a lot

  12. Page 403: Should read “First, validate any email addresses using regular expressions, covered in Chapter 14 “Perl-Compatible Regular Expressions”,”

  13. Hi, page 261 sidebar talks about using die() and exit() constructs. You have “You’ll commonly see die() and exit() used in an OR conditional. For example: include(‘config.inc.php’) OR die(‘Could not open the file.’);”

    Your example doesn’t work and the PHP Manual doesn’t have an ‘OR’ as a conditional. http://www.php.net/manual/en/language.control-structures.php

  14. Page 57

    TIP You only need to use the curly brackets
    to surround an associated array used within
    quotation marks. All of these array references
    are fine:
    echo $_POST[‘name’];
    echo “The first item is $item[0].”; <——– echo "The first item is {$item[0]}.";
    $total = number_format($cart['total']);

    • No, that’s actually correct as is. The point is that associative arrays–those that use strings for indexes–need the curly brackets within quotation marks. Numerically indexed arrays as in that code is fine without the curly brackets.

  15. Hi there,
    on page 192 (right segment). you wrote: “(0, 1, 3, ‘Database Design’, ‘Okay, thanks!’, UTC_TIMESTAMP( )),”

    I think it must be (3,1,3) instead of (0,1,3) because the message is an answer and the third message added to the database will have a message_id of 3,so replies to that message need a parent_id of 3.

    Plus shouldn’t we have a table subject, because we don’t respect the 2NF. It is like the example you gave page 172 (“Going back to the cinema example, a movies table (Table 6.4) would have the
    director Martin Scorsese listed 20+ times.”. In our case a message table is going to have “Database Design” listed many times.

    Kind regards,

  16. Hi Larry,

    It’s me again. I know I am antipathetic :-).
    It is not a mistake but just a precision. On page 196 picture C. In the table accounts it is Indexes: PRIMARY customer_id not customer. because when you created the table on page 198 you wrote INDEX (customer_id).
    I know, it was not worth mentioning.

  17. Spencer Henderson, Jr. August 6, 2012 at 11:58 pm

    I am working on Script 1.9 in Dreamweaver. It is giving me a syntax error where I define ‘TODAY’. I don’t know where I’m getting the syntax error as my code is exactly like it is in the book. I cannot find it anywhere on the errata. This is the ONLY place where I’m getting the error. The code reads:

    define (‘TODAY’, ‘August 6, 2012′);

    Is there any way you can tell me what is wrong? Thanks!

  18. Spencer Henderson, Jr. August 6, 2012 at 11:59 pm

    BTW, it’s in Chapter 1. Thanks!

    • Spencer Henderson, Jr. August 7, 2012 at 10:59 pm

      Please disregard my previous two messages. I have found my syntax error. The opening and closing of any PHP document goes like this:

      However, my code in Script 1.9 read like this:

      Apparently I had added a space where there shouldn’t have been one.

      Thanks anyway.

  19. So on pg. 405, you said, “On line 58 of Script 13.1, the $scrubbed array should be reset instead of $_POST, as this new array is what the form will use,” so what should line 58 read?

  20. this is the the page 405 chapter 13

    The conditional therefore says that if that function’s results do not equal FALSE (i.e., $v was not found in $value), return an empty string.

    in above the paragraph which should really have said (i.e $v was found in $value) am i right pls correct me if i am wrong.

  21. Page 76 in the gray box – Absolute vs. Relative Paths. The first include referencing C: should have backslashes rather than forward slashes:

    Absolute paths in Windows always begin with C:\. The forward slash is used on Unix/Mac OS X and relative paths.

    • Actually, if you’re using Windows, you have to use two backslashes because one backslash is the escape character. Or you can just use forward slashes, as I do in the book (i.e., that’s not an error).

  22. Page 514 line 46 the form submission if condition is $_POST[‘start’], $_POST[‘end’] but the form names on line 79 and 80 respectively are name=”start_date” and name=”end_date”. The entries should match exactly or the if condition will never be true.

  23. We will try this one more time. The LESS THAN + FORWARD SLASH + a + GREATER THAN are missing from page 635 script 196 on line 35 and also from downloadable file.

  24. Hi Larry – wonderful book, thank you. Page 80, inscription under image C states: “You can omit or change any value and rerun the calculator… ” This is almost true, except if you omit number of payments, you will be dividing the total by 0, which will result in a warning message and empty output.

  25. Page 627 states: “In case the print’s name, size, or description uses potentially problematic characters, each is run through htmlspecialchars()…” However, script 19.2( p. 621 and in the code download) omits the htmlspecialchars for the description.

  26. On page 210, a % sign is missing before Y inside the parentheses of the DATE_FORMAT() function. Instead of the year, a capital Y appears in the result, like this: “December 6th, Y”.

  27. More: Pg. 334, step 6. should include the closing ?> tag at the end, as it is done in the corresponding part of the script 11.1 on the previous page. Without that tag, the page won’t be displayed, and the error will appear instead.

  28. Pg. 360, step 9: readfile ($image); is missing, even though the explanation for it is provided at the end of the step, which may actually be confusing, rather than helpful. (The corresponding Script 11.5 on Pg. 358, however, does include the necessary function, at the very bottom.)

  29. Pg. 359. Step 7: “The image itself can be downloaded from the book’s corresponding Web site (www.LarryUllman.com, found with all the downloadable code) and should be placed in an images folder.” Actually, there’s no image provided anywhere in the downloadables. (Or it’s really, really well hidden.)

  30. Pg. 354, Step 8: the bit of code that outputs the link to an image is missing the closing tag. The corresponding Script 11.4 on previous page does include the tag.

  31. Chapter 14, “PERL-Compatible Regular Expressions”, Pg. 450, second paragraph: “Of these delimiters, the most important is i,
    which enables case-insensitive searches.” I think the word “modifiers” should be used instead of “delimiters” in that sentence.

  32. Error in the errata? The second “Chapter 7: Advanced SQL and MySQL” item has page 201. Should this be 210?

  33. It would be helpful, for those of us with the eBook version, to provide further information regarding where an error appears when it is outside of a script (where line numbers are great). For example, “Page 193″ means very little without a reference to a specific section within Chapter 6, since there are no page numbers in the eBook. I’m planning to use the book to teach someone PHP, and I’d like to be able to highlight the errata before we get to it.

  34. Larry,
    I have attempted to validate the header.html file from Chapter 17 and it still gives an error. Here it is from validator.w3.org:

    Line 38, Column 157: document type does not allow element “form” here; missing one of “object”, “applet”, “map”, “iframe”, “ins”, “del” start-tag
    …” class=”navlink”>Logout

    The mentioned element is not allowed to appear in the context in which you’ve placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you’ve forgotten to close a previous element.

    One possible cause for this message is that you have attempted to put a block-level element (such as “” or “”) inside an inline element (such as ““, “”, or “”).

    PLEASE ADVISE. I noticed that your code is identical to mine in this area. Perhaps it could be this instead: <form action… then then ? Thanks for checking on this for me!

  35. Paul Merideth June 21, 2014 at 2:51 am

    Isn’t line 32 in script 13.1 ( pg. 405) incorrect? It’s listed as:

    $value=str_replace(array(“\r”, “\n”, “%0a”, “%0d”), ‘ ‘, $value);

    When I run this code using double quotes around \r and \n, I get spaces in the array. I have to use single quotes to make the array contain the \r and \n characters that are being searched for. I can’t find any errata for this script, so I’m wondering if I’m missing something?

    Paul Merideth

    • Hi Paul – that is exactly the intent of what he is trying to accomplish. In the explanatory text in item 5 on the same page (405) he explains the details of what is going on, i.e. “:Replace any newline characters with spaces…” If you change the double quotes to single quotes, then the backslash-r and backslash-n are no longer interpreted as the newline characters, so it defeats the purpose of this line of code. Larry does note that “…any found newlines will just be replaced by a space. This means that the submitted value could lose some of its formatting, but that’s a reasonable price to pay to stop spam.”

      His code, as written, does what he wants it to do. Hope this helps!

  36. Santilal Parbhu July 9, 2014 at 11:37 pm


    I am not sure if this is an error or I have understood things badly. On P211, should the first virtual table have in the username column: trouster, funny man, funny man, Gareth, Gareth. I say this because in the “Messages” table the userID is 1,2,2,3,3.

    By the way, this is another excellent book. So easy to read and understand. Thank you.



  37. In the Book-O-Rama I am trying to add the item to the cart by clicking on the Add to Cart button – when I hover over the button I see the correct ISBN number but when I click the button I get this error
    “Notice: Trying to get property of non-object in C:\inetpub\wwwroot\PHPBookStore\book_fns.php on line 90 Fatal error: Unsupported operand types in C:\inetpub\wwwroot\PHPBookStore\book_fns.php on line 91″

    Any help is appreciated.

  38. Your appendix A has an error. On page A11, it prints:

    ON temp.* TO
    IDENTIFIED BY ‘BroWs1ng'; <– notice the password uses the number one

    but on page A14, it prints

    mysqli_connect ('localhost',
    'webuser', 'BroWsIng', 'temp');

    The passwords are not consistent. Either use a number or use capital I but not both.
    Thank you

  39. I found discrepancy. Page 530. The second point is missing session_start ();, which is in the 17.1 script.

  40. Hi there,
    on page 192 (right segment). you wrote: “(0, 1, 3, ‘Database Design’, ‘Okay, thanks!’, UTC_TIMESTAMP( )),”

    I think it must be (3,1,3) instead of (0,1,3) because the message is an answer and the third message added to the database will have a message_id of 3,so replies to that message need a parent_id of 3.

Comments are great, but I'd strongly prefer any requests for assistance get made in the support forums. Thanks!