Foundation PHP 5 for Flash: Corrections and Updates
NOTE: This page is no longer actively maintained. Its original purpose was to keep readers up to date with any new developments since the book's original publication in March 2005. Factual errors and corrections were hosted on the friends of ED website, which closed in 2011. I have managed to find the original corrections, which are now listed below.
Chapter 1: Installation issues
Apache 2.2 series requires PHP 5.2 or higher on Windows: For details of how to use the new Windows installer for PHP 5.2.x, please see the instructions in the Tutorials section of this site.
Universal binary of PHP 5 for Mac Marc Liyanage now creates Universal Binary versions of PHP, which require a minimum of OS X 10.4. If you are using OS X 10.3, you are restricted to using PHP 4. Check Marc Liyanage's site for the most up-to-date information. An alternative solution, which I have not tested, is MAMP.
Chapter 5: Changes to Apress RSS feed
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']));
}
Chapter 6: Changes to phpMyAdmin installation
Since version 2.7.0, phpMyAdmin no longer contains a file named config.inc.php. All the main configuration settings have moved elsewhere, and you need to create your own version of config.inc.php containing only those settings that you want to change. The following instructions replace steps 5 through 9 on pages 276-277 (they assume that you have installed the latest versions of PHP and MySQL, and that mysqli has been enabled in PHP):
- Open a text editor and enter the following code (correct as of phpMyAdmin 2.8.0):
<?php $i = 1; $cfg['Servers'][$i]['extension'] = 'mysqli'; - If you are the only user of your computer and don't need to password protect access to phpMyAdmin, add the following code:
Replace "myRootPassword" with the root password that you chose for MySQL. Save the file as config.inc.php in the main phpmyadmin folder. Continue with step 10 in the book.$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'myRootPassword'; ?> - If you want to password protect access to phpMyAdmin, add the following code instead:
Save the file as config.inc.php in the main phpmyadmin folder. Continue with step 10 in the book.$cfg['Servers'][$i]['auth_type'] = 'http'; ?>
Changes to phpMyAdmin 3.0
The user interface for defining new tables in phpMyAdmin has changed in phpMyAdmin 3, which was released in late September 2008. See my blog entry for a list of the differences.
Corrections
- 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,
getUpdateshould 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".






