Corrections for:

Foundation PHP for Dreamweaver 8

View book details

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 Foundation PHP for Dreamweaver 8, 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: Feed ?

Installing Apache on Windows

The Windows version of PHP 5.2.0 now supports Apache 2.2.x, and comes with a greatly improved Windows installer. Please visit the author's website at foundationphp.com for instructions on how to use the installer.

If you want to use the ZIP version instead of the installer with Apache 2.2.x, use php5apache2_2.dll in place of php5apache2.dll in step 3 on page 67.

All

Dreamweaver 8.0.2: On May 9, 2006, Adobe issued a point release of Dreamweaver (the 8.0.2 updater), which makes security improvements to the PHP code generated by the server behaviors used in Chapters 8 through 11. As a result, the line numbers shown in many screenshots are now different. In most cases, the difference is approximately 5 lines. Where the difference is substantial or likely to cause confusion, it is listed below, along with other changes introduced by Dreamweaver 8.0.2.

Please make sure you follow the instructions for the correct version of Dreamweaver. To find out which version you're using, click About Dreamweaver in the Help menu (Windows) or Dreamweaver menu (Mac OS X); and then click once in the panel that appears: the version number is at the bottom of the panel. Separate download files have been created for Dreamweaver 8.0.2.

PHP Hotfix for Dreamweaver 8.0.2

Adobe has released a PHP Hotfix that fixes several problems introduced in or discovered since the release of Dreamweaver 8.0.2. You are recommended to install the hotfix, which can be obtained directly from Adobe Support. For further details, see the Adobe Technote at www.adobe.com.

p.84

Configuration File Path: Since PHP 5.2.3, the actual location of php.ini is displayed separately as "Loaded Configuration File".

p.104

Figure 4-3. The nested titlebar <div> is missing from the diagram. It should be shown within the wrapper <div>, surrounding the "East-West Seasons" masthead graphic, as shown below.

screenshot

p.112

In the html, body style rule, there should be a semicolon after color: #373737.

p.119

Due to a typo, the conditional comments for IE5 are incorrect. The code should use a double-hyphen, rather than an em dash.

<!--[if IE 5]>
<style>
body {text-align: center;}
#wrapper {text-align: left;}
#nav a {width: 146px;}
</style>
<![endif]-->

(Thanks to Brenda Egeland for spotting this)

p.149

In Table 5-3, 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.156

The final paragraph should read:
The implication of this is that when you need all conditions to be met, you should design your tests with the condition most likely to return false as the first to be evaluated. When you need just one condition to be fulfilled, place the one most likely to return true first.
(Thanks to Jon Morrow)

p.166

In step 16, the cols="60" and rows="6" attributes have been omitted from the <textarea> tag. The same error applies to the code in step 21 on page 184.

p.171

In step 5, echo has been left out of the PHP code in the action attribute. It should read action="<?php echo $_SERVER['PHP_SELF']; ?>". However, the page works as intended even without echo. This is because a form with no action attribute automatically reloads the same page. Adding echo inserts the correct pathname explicitly.

p.178

In the second paragraph from the bottom, the second sentence should read:
"Defining a regex for an email address is notoriously difficult, so the one I have created for the Email address check snippet concentrates on rejecting all illegal characters, while checking for one thing every email address must have: an @ mark in the middle."

p.232

Mac users who are running versions of OS X older than 10.4 are unable to create hidden files using either TextWrangler or BBEdit. pico can be used instead, as documented here:

  1. Open Terminal
  2. Type the following command followed by Return:
    pico ~/.profile
  3. This opens the file ready for you to type the path:
    export PATH=”$PATH:/usr/local/mysql/bin”
  4. Save the file by pressing Ctrl+X, and then press Y and Return.
p.237 - 238

The installation procedure for phpMyAdmin changed twice in the first three months since the book's release, affecting the first and second printings, but in different ways. (These instructions are correct as of version 2.8.0.)

If step 5 of page 237 in your edition begins with the words "You to create a short configuration file...", simply add the following line of code immediately after the opening PHP tag in steps 6, 7, and 10 on page 238:

$i = 1;

If, on the other hand, step 5 refers to an 845-line file called config.inc.php, please note the following changes:

All the main phpMyAdmin configuration has been moved to a different file, and you need to create a much smaller config.inc.php (just a couple of lines) yourself.

If you are the only user of the computer and don't need to password-protect
access to phpMyAdmin, this is what the file should contain:

<?php
$i = 1;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['password'] = 'mysqlRootPassword';
?>

(Use your real root password in place of mysqlRootPassword.)

If you want to protect access to phpMyAdmin by prompting for a password, config.inc.php should look like this:

<?php
$i = 1;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['user'] = '';
?>

If you are using PHP 4 and/or MySQL 4.0 or earlier, do not include this line:

$cfg['Servers'][$i]['extension'] = 'mysqli';

Some readers have reported being unable to login to phpMyAdmin after creating config.inc.php. If you experience difficulties, add the following lines of code to config.inc.php:

$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['user'] = 'root';

This should not be necessary, as these are the default settings in phpMyAdmin. However, adding them appears to solve the problem.

The phpMyAdmin documentation contains details of a setup script that creates config.inc.php automatically. However, this involves creating a temporary folder, and then moving the file to a new location. It's much quicker to create the file by hand, particularly on Mac OS X, because the temporary folder needs global write permission.

p.258

Steps 1 and 2: In phpMyAdmin 2.7.0 and later, the form to load data from a SQL file has moved from the SQL tab to the Import tab. This also affects the instructions on pages 417 and 474.

p.265

In Dreamweaver 8.0.2, the SQL query shown on line 4 in the screenshot in step 17 is now created on line 33. The include command referred to in step 18 remains on line 1

p.305

<label for="textarea">Quotation:</label>
should read:
<label for="quotation">Quotation:</label>

(Spotted by Andew Kellett)

p.308 - 309

A bug in Dreamweaver 8.0.2 strips CONCAT() out of the SQL query when you close the Advanced Recordset dialog box. This has been fixed by the PHP Hotfix for Dreamweaver 8.0.2 (see top of page). As a temporary measure, close the dialog box at the end of step 1, and make the changes in step 2 directly in Code view.

p.312 - 313

The Dreamweaver 8.0.2 updater (released May 9, 2006) changes the way you define temporary variables for SQL queries. The Add Parameter dialog box has been replaced by an Edit Variable dialog box, which contains one extra field: Type. This new field offers three self-explanatory options: Numeric (default), Text, and Date.

screenshot

The new field serves a two-fold purpose: it checks that a numeric runtime value is actually a number, and it automatically encloses text and dates in quotes. This not only makes the construction of SQL queries easier, it increases security. Scripts will fail if anyone attempts to inject text where a number is expected. Consequently, you should always choose the correct setting for Type.

Because Dreamweaver 8.0.2 automatically inserts quotes around text variables, the code in step 7 no longer needs quotes. It should now read:

WHERE authors.first_name = var1 and authors.family_name = var2

screenshot

p.322

In Dreamweaver 8.0.2, set the Type of var1 to Numeric in step 6.

p.323

Step 10: In line 3, “select family_name” should be “select first_name”

p.334

Step 1: Action should be set to "session2.php" (not "submit2.php")

p.342

In Dreamweaver 8.0.2, the code on lines 3 - 22 in the screenshot is created around lines 32 - 51. All other line references need to be adjusted accordingly.

p.352

Step 16 should read "Change the code shown on line 153..." (not
142).

p.359

In Dreamweaver 8.0.2, the SQL query shown on line 88 of the screenshot in step 10 looks like this:

$LoginRS__query = sprintf("SELECT username FROM users WHERE username=%s",GetSQLValueString($loginUsername, "text"));

If using DW 8.0.2, change the code in step 10 like this:

WHERE username=%s AND user_id != %s", GetSQLValueString($loginUsername,"text"), GetSQLValueString($_POST['user_id'], "int"));

The code does the same thing, but incorporates the new security checks implemented by Dreamweaver 8.0.2.

p.365 - 375

The 30-day trial version of MX Kollection 3 has been withdrawn following the takeover of InterAKT by Adobe. This is something over which neither the author nor friends of ED has any control. However, the first half of Chapter 10 shows how to build the same functionality with Dreamweaver server behaviors. The purpose of the final section is to demonstrate the different approach taken by a commercial extension.

p.382

The quotes surrounding ../images_blog/ in line 3 of the code in step 1 don't match. The closing quote should be single, not double.

p.401

In Dreamweaver 8.0.2, set the Type of var1 as Numeric in step 6.

p.403

In step 14, a closing PHP tag should be inserted at the end of the first line of code.

p.404

In Dreamweaver 8.0.2, the code will be around line 68, instead of 38.

p.415

The Adobe takeover of InterAKT means the MX Looper is now available only as part of Kollection. Use the PHP Horizontal Looper (a free extension by Tom Muck - www.tom-muck.com/) instead. Revised instructions for pages 420-421 can be found at foundationphp.com.

p.445

A bug in the XSL Transformation server behavior prevents the news feed from displaying correctly. This has been fixed in the PHP Hotfix for Dreamweaver 8.0.2 (see top of page). A temporary workaround is to amend a file that Dreamweaver creates in the includes/MM_XSLTransform folder of your site. Open MM_XSLTransform.class.php, and comment out the four lines that begin with $old_error_handler (use Edit > Find and Replace).

p.453

In step 5, the code should read:
position() > 1 and position() != last()