Corrections for:

Foundation PHP 5 for Flash

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 5 for Flash, 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 ?

Chapter 11

If you would like to use v2 components, download the bonus file, and study the inline comments on frame 1 of the actions layer in the dateSelector movie clip.

Apache Installation 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 php5apache.dll in step 2 on page 21.

p.10

Which version of Apache? The latest versions of PHP are compatible with Apache 2, so users of Windows 2000, Windows XP and later are now recommended to use Apache 2. If you have an older version of Windows, you should use Apache 1.3. (Applies to Windows only).

p.12

In step 6, XP Home users should select the option to run Apache as a service for all users unless they specifically want manual control. (Thanks to Jason for confirming that it works.) (Applies to Windows only).

p.18

For compatibility with more recent versions of phpMyAdmin and MySQL, you should also enable php_mbstring.dll in step 9 by removing the semicolon at the beginning of line 571 in the screenshot. (Applies to Windows only).

p.21

p.21 In step 3 of "Adding PHP to Windows 98 and ME", the = sign is missing from the line of code. It should read:
set PHPRC=C:\php5
Thanks to Leon Smith for pointing that out.

p.68

step 1: "...highlight frame 40 on all layers and enter a blank keyframe (F5)": The frames added by pressing F5 are not keyframes, but standard ones, which is the intention. (Well spotted, Viv!)

p.76

step 1: In Mac OS X, this script requires read/write permission applied to the phpflash/ch02 folder. Highlight the ch02 folder in Finder, and set the same permissions as described on pages 335-6.

No changes are required for Windows.

p.79

Flash uses UTF-8 (Unicode) encoding, so accented or non-alphanumeric characters will not display correctly in emails sent from the Flash form. To solve this problem, add the correct Content-Type header to the email by amending the code in step 6 like this:

$additionalHeaders = "From: Flash feedback\n";
// next line sends email as Unicode
$additionalHeaders .= "Content-Type: text/plain; charset=utf-8\n";
$additionalHeaders .= 'Reply-To: '.$_POST['email'];

The same change should be made to the full listing in step 8 on page 80. Eagle-eyed Vince Wessellmann has pointed out that the last line of $additionalHeaders is different in the listing on page 80. For the sake of continuity, they should be the same; but both versions are equally valid, and will produce the same results. The different syntax is explained in the box on page 185.

p.87

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 $c to 3 and the result is correct.

p.89

In step 5, the result of the number_format() example should be "1 234,57" since number_format() rounds up decimal fractions of 5 and above.

p.90

In step 10, you should change the script back to the way it was in step 4 - not 3. (Thanks, Erik).

p.92

The example for min() should read $a = min(2,34,-20); (spotted by Paul C).

p.93

The maximum random value on Mac OS X and Linux is 2147483647. (Thanks to Erik again for spotting the missing 4).

p.105

The formula for square meters to square yards should read "Square meters [division sign] .836". (Noticed by Zain).

p.122 - 124

The book uses Flash MX UI components, which can be downloaded free of charge from the Macromedia Exchange. However, some users of Flash MX 2004 and Flash 8 have requested more detailed instructions for Flash version 2 components. Unfortunately, the highlighted section on page 122 is based on the Macromedia documentation, which is in itself incorrect (cough, cough). For a version 2 combo box, instead of dropDown_cb.value, you should use dropDown_cb.selectedItem.data in both the comboChange() and doConvert() functions.

To create an event listener for a version 2 combo box, substitute the code in step 3 on page 123 with the following:

var comboChangeListener:Object = new Object();
comboChangeListener.close = comboChange;
dropDown_cb.addEventListener("close", comboChangeListener);

p.124

Step 3: For the sake of consistency with the rest of the book, an equal sign should be inserted after "ck", just before the closing quotes in the sendAndLoad() URL. The URL works correctly with or without the equal sign because everything after the question mark is simply to force the browser to clear its cache.

p.155

In step 7, line 5 should read: "…the code to the right of the colon…" (not semicolon).

p.161

In the final block of code, there should be a colon instead of a semicolon after case 'mToYd'.

p.192

In the first code example, a rogue space has crept in between "helper" and the closing single quote.

p.201

In Table 5-2, the array argument for array_push() has been omitted. It should read array_push(array, value1 [, valueN]).
(Spotted by Matthias.)

p.204

Line 2 refers to "output shown at the right". The Orcs must have sneaked into the printing works when we weren't looking, and moved the screenshot to the left.

p.217 - 219

The Apress RSS 1.0 feed used in the project in Chapter 5 is no longer active. Change the code in step 8 on page 217 as follows:

$urls[1] = 'http://blogs.apress.com/wp-rss2.php';

The new feed uses pubdate instead of dc:date, so you also need to change the code on page 219. The following lines are affected:

$date[$k] = substr($feed[$i]['items'][$j]['dc']['date'],0,10);
$time[$k] = substr($feed[$i]['items'][$j]['dc']['date'],11,8);

Amend them like this:

if (isset($feed[$i]['items'][$j]['dc']['date'])) {
$date[$k] = substr($feed[$i]['items'][$j]['dc']['date'],0,10);
$time[$k] = substr($feed[$i]['items'][$j]['dc']['date'],11,8);
}
elseif (isset($feed[$i]['items'][$j]['pubdate'])) {
$date[$k] = date('Y-m-d', strtotime($feed[$i]['items'][$j]['pubdate']));
$time[$k] = date('H:i:s', strtotime($feed[$i]['items'][$j]['pubdate']));
}

p.275

para 5: MySQL Administrator is now also available for Mac OS X 10.3

p.276 - 277

All the main phpMyAdmin configuration has been moved to a different file since version 2.7.0, 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 (correct as of version 2.8.0):

<?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.317

In step 9, the final argument passed to the Database constructor should be 'phpflash' (in quotes), and not $dbName. The code in the download file is correct.

p.320

In the code five lines from the bottom of the page, lettersLeftToGo– should be lettersLeftToGo--. The same misprint appears four lines from the bottom of page 321. (Thanks, Vera).

p.379

The first paragraph after the code block in step 7 refers to the Database class created in Chapter 6. It was actually created in Chapter 7, and the scripts are available in classes folder of the download files.

p.381

An equal sign is missing in the fourth line of code in step 10. It should read: echo 'duplicate=y&message='.urlencode($duplicate); (Thanks, Brymstone).

p.401

The code in the third line from the top of the page should read:
echo 'status=goodbye';
The final part of the last sentence of step 2 should also read "... and send a variable called status back to Flash with a value of goodbye. (Spotted by euphemia)"

The download file contains the correct code.

p.453 - 454

In steps 3 and 7, of the 'Wiring up the update buttons' section, getUpdate should be replaced with: getDetails

p.461

Step 2.
echo 'duplicate=n&message='.urlencode($updated);
should be:
$output = 'duplicate=n&message='.urlencode($updated);

p.518

Focus point, line 2: insert "company" after "hosting" (to read "hosting company limits the number..."

p.522

Taking the CMS for a quick test drive. Clicking the "Get prices" button generates an error in PHP 4, because the underlying script uses SimpleXML, which is new to PHP 5. See pages 596-601 for a full description. The rest of the application is fully compatible with PHP 4.

p.696

col 2: "SMTPsetting" should read "SMTP setting".