Corrections for:
PHP Solutions:
Dynamic Web Design Made Easy
While we hope that our books are error free, once in a while a mistake makes it into print. Changes to a book's technology following publication can also create issues.
Below, you'll find a list of updates and corrections for PHP Solutions: Dynamic Web Design Made Easy, ordered by page number. If you spot an error we've missed, feel free to let us know by submitting it via our errata form
You can subscribe to this page, and so receive any additional corrections via RSS:
?
- p.41
(Final paragraph) Since PHP 5.2.3, the version of php.ini read by your computer at startup is displayed as "Loaded Configuration File".
- p.41
Insert the following between the first and second sentences of the final paragraph: "Since PHP 5.2.3, the location of php.ini is shown on the line immediately below as Loaded Configuration File."
- p.66
In Table 3-1, the result shown for modulo division, although mathematically correct, would be 0 in a PHP script. This is because PHP converts numbers to integers when performing modulo division. Change $z to 3 and the result is correct.
- p.96 - 102
PHP Solutions 4-3 and 4-4 pass the superglobal variable $_SERVER['SCRIPT_NAME'] as an argument to basename() to determine the name of the current page. Unfortunately, if your hosting company runs PHP as a
CGI on Apache, this outputs "php.cgi" instead of the name of the actual page. To get round this problem, use $_SERVER['SCRIPT_FILENAME'] instead of $_SERVER['SCRIPT_NAME'].(Thanks to webinator for testing this fix.)
- p.132
In step 4, the third line of code should read as follows:
if ($_POST && isset($missing) && !empty($missing)) {This ensures that the first error message is displayed only if not all required fields have been filled in. It's possible that the user has filled in all fields, but the mail was not sent due to server error. (Thanks to Caroline Schnapp for pointing this out.)
- p.142
Add the following at the foot of the page: "When adding extra form elements, don't forget to add their names to the $expected array. Otherwise they won't be processed."
- p.180
Delete the following words at the end of the final sentence: "and notes changes planned in PHP 6."
- p.181
The changes to allow_url_fopen and and allow_url_include were brought forward from PHP 6 to PHP 5.2. The change to safe_mode is still planned for PHP 6.
- p.186
In the final paragraph of step 3,
$users[0]['password']should be$users[1]['password']. (Spotted by patfkellogg)- p.198
In step 4, buildImageList5 and buildImageList4 should be buildFileList5 and buildFileList4 respectively. (Thanks to FLA Rider)
- p.222
In the switch statement, the word "created" has been wrongly appended to the value of $thumb_name in three places. In each case, the correct code should be $name followed by the appropriate filename extension, for example:
$thumb_name = $name.'_thb.jpg';(Thanks to FLA Rider)
- p.226
There's a step missing after step 3 in PHP Solution 8-3. Since
$originalnow refers to the temporary file, you also need to change the line that assigns the value to $name. Replacebasename($original)withbasename($_FILES['image']['name']), so the complete line looks like this:$name = preg_replace($imagetypes, '', basename($_FILES['image']['name']));(Thanks to genji for spotting this omission.)
- p.227
In the final paragraph, upload_test02.php should be upload_thumb02.php. (Thanks to FLA Rider)
- p.324
An opening curly brace is missing at the end of line 4 of the code in step 2. It should read:
if (!@include('includes/connection.inc.php')) {
(Thanks to Pat Kellogg.)- p.334
In Step 2, the line that sets the value of $totalPix should be amended in the PDO code ONLY as follows:
$totalPix = $row;This is because the PDO method
fetchColumn()retrieves a single column, rather than the entire row. (Thanks to grillecloth for pointing out that the original code produced unexpected results with more than nine images listed in the database.)- p.405 - 406
NULL should be in quotes in the following line at the foot of page 405:
$image_id = NULL;
Amend the first paragraph at the top of page of page 406 to read as follows: "If $image_id contains no value or if it's not a number, its value is set tothe string 'NULL'. Inside the SQL query, this is treated as the keyword NULL because $image_id is not enclosed in quotes. Although this sounds counter-intuitive, the SQL query is built as a string. It's the use of quotes inside the query that determines how MySQL treats a value."- p.415
The lines of code :
"FROM column_name LEFT JOIN column_name ON matching_condition"
"FROM column_name LEFT JOIN column_name USING (column_name)"should read:
"FROM table_name LEFT JOIN table_name ON matching_condition"
"FROM table_name LEFT JOIN table_name USING (column_name)"(Thanks to Mark Anderson)