- ISBN13: 978-1-59059-906-8
- ISBN10: 1-59059-906-3
- 569 pp.
- Published Dec 2007
- Print Book Price: $44.99
- eBook Price: $31.49
Errata Submission
If you think that you've found an error in Practical Web 2.0 Applications with PHP, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.
Errata
| Issue | Author's Response |
|---|---|
| Chapter 11 p.403. Only shows alternates without images. I don't think it is your error but after a few hours of troubleshooting it, found that I just needed to increase the php memory limit from 8m to 16m. Unfortunately nothing tells you this unless you make the code stop at various places until you get a message that the memory has been used. |
Thanks for this note |
| Hi sir, There's a problem in Chapter 2. I'm getting this error: Notice: Zend_Loader::Zend_Loader::registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead in /Applications/XAMPP/xamppfiles/htdocs/phpweb20/include/Zend/Loader.php on line 207 It appears that the autoloader is deprecated. Please correct this to the latest version. I'm new to the PHP world and programming and don't know how to correct this problem. |
You can do something as follows: $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); |
| In Chapter 14, page 520 in the EmailLogger, the function setEmail creates a new Zend email validator by: $validator = new Zend_Validate_EmailAddress(); This is a problem if your $_SERVER[SERVER_ADMIN] is root@localhost, because the local host will not show up as a valid email domain. I solved the problem by changing the line to read: $validator = new Zend_Validate_EmailAddress( Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL); |
This appears to be somewhat of an edge-case but is a valid solution if this is what you need to do Thanks! |
| hi, I think there os a small error on chapter 10, page 399, listing 10.5: if (count($_tags) == 0) return; $where = array('post_id = ' . $this->getId(), $this->_db->quoteInto('lower(tag) in (?)', $tags)); should be: $this->_db->quoteInto('lower(tag) in (?)', $_tags)); else you'd be searching within the untrimmed & un-strtolowered user parsed array. |
Hi This is in fact an error and your solution is correct Thanks! |
| Hi, I think there is an errata on chapter 4, page 75, listing 4-1. Where it says: $this->user->type = 'member'; it should say: $this->user->user_type = 'member'; I hope this helps! Best regards, Uder |
Solution provided by submitter is correct |
| I have the following errors. I have plugins dir right. Copy the files from the website. I check dir structure and typo errors but could not find anything. Fatal error: Smarty error: [in account/register.tpl line 4]: syntax error: unrecognized tag 'geturl' (Smarty_Compiler.class.php, line 599) in /var/www/library/Smarty/Smarty.class.php on line 1092 |
This means Smarty is unable to find the geturl plug-in, which should be located in ./include/Templater/plugins/function.geturl.php If that file exists and the error occurs, it means that directory hasn't been added to Smarty's plugin directory in ./include/Templater.php |
| chapter 6, page 173 (italian edition by Apogeo). Using ZendFramework 1.7.0 instead of 1.0.2, the application produces links like "phpweb20//phpweb20/index". Using older version the problem disappear. Thanks |
Try the suggested solution at the following URL (for listings 6-3 and 6-4) http://www.myphpbook.com/articles/errata |
| Chapter 6, pages 211-212: from the bottom of pg 211 to the top of pg 212. The code is: if ($validate) { $json = array( 'errors' => $fp->getErrors() ); $this->sendJson($json); } If you look at the class FormProcessor $_errors is initialized to an array on line 4: protected $_errors = array(); So even if there is no error when you call $fp->getErrors() and assign it to $json there is an error element inside the array, in the case where every thing validates it is an empty array. This leads to the javascript in UserRegistrationForm.class.js to always think is has an error and never let the user complete registration. Solution: if ($validate) { if ($fp->getErrors()) { $json = array( 'errors' => $fp->getErrors() ); } else { //user's submission validates, allow the user to register $json = array(); } $this->sendJson($json); } |
You could go either way with this. Use the solution you provided, or ensure the javascript code checks for at least one error in the array. I believe the issue is to do with a change in the arrays/hashes are handled in Prototype |
| Chapter 13, Page 490 you have the function locationsManageAction() the Capital M in manage causes the Manage Location page to fail, it should be a lowercase m: locationsmanageAction() | Technically this isn't an error in the book since it worked when published, but when a newer version of ZF came out calling an action locationsManageAction() would result in the view renderer looking for locations-manage.tpl instead of locationsmanage.tpl. |
| Chapter 11, pages 421 and 424 There is an inconsistency between listing 11-51 and 11-55. The former has the following code: <img src="{imagefilename id=$image->getId() w=150}" /> which works, while the later includes the following: <img src="/utility/image?id={$image->getId()}&w=150" /> and this one doesn't work. |
This submission is valid. The {imagefilename} plugin was created to help prevent DoS attacks but it appears the latter code was not updated. Page 424 should in fact read: <img src="{imagefilename id=$image->getId() w=150}" /> |
| Chapter 11, page 424. The caption for listing 11-54 reads: Loading Lightbox on the Blog Post Details Page (header.tpl) It should read: Loading Lightbox on the Blog Post Details Page (view.tpl) |
This submission is correct. The listing caption is incorrect: the referenced filename is view.tpl, not header.tpl |
| Chapter 11, page 397, listing 11-28 At the third if statement of the smarty_function_imagefilename function, the book reads: if (!isset($params['w'])) $params['h'] = 0; While it should read: if (!isset($params['h'])) $params['h'] = 0; |
This submission is correct - the wrong parameter name is checked when initializing the height value. |
| Chapter 11, page 390, listing 11-20 The sentence: $fullpath = $this->getFullpath(); Should be: $fullpath = $this->getFullPath(); Best regards, Ramón Bultó |
This submission is correct. Note however that if you don't fix it in your own code it does not matter since PHP doesn't care about the case in function calls. |
| Chapter 11, page 280, listing 11-5. On the line where the $url variable's value is set there is a case typo with the name of the function getId(). The book reads: $url = $this->getUrl('preview') . '?id=' . $post->getid(); while it should read: $url = $this->getUrl('preview') . '?id=' . $post->getId(); Regards, Ramón Bultó |
(This occurs on Page 380, not 280) The provided solution is correct. Note however that PHP doesn't enforce the case on function calls - only for variable names, so fixing this in your own code is not critical. |
| On chapter 6, page 214. If I am not wrong, I believe that the end of the second pharagraph under the Handling the Form Submission header should read: (that is, processing the form but not creating the user if there are errors) Instead of: (that is, processing the form but not creating the user if there are no errors) |
This submission is correct - the word "no" should be omitted from the sentence. |
| On chapter 11, page 374. The book reads (just before listing 11-2): This code should be stored in BlogPostImage.php which resides in the ./include/DatabaseObject class. It should read: This code should be stored in BlogPostImage.php which resides in the ./include/DatabaseObject directory. |
This submission is correct, the final word should read directory, not class. |
| Chapter 9, page 316. The book reads that the file blog-post-summary.tpl is stored in ./templates/default/user/lib, while it should be stored in ./templates/user/lib, as stated in index.tpl described on listing 9-13 at the same page. I hope you find this information helpful! Best regards, Ramón Bultó |
Submitter is correct, this should read ./templates/user/lib |
| On chapter 8, page 293-294. There is a problem when installing FCKeditor the way it is explained in the book, at least under the latest FCKeditor release (2.6). When the edit blog page is loaded it generates the following php error: PHP Fatal error: Call to undefined function FCKeditor_IsCompatibleBrowser() in \include\FCKeditor.php on line 162 That is because the main FCKeditor file is fckeditor.php, which defines the FCKeditor_IsCompatibleBrowser function and at the end, depending on the version of PHP, it includes either fckeditor_php4.php or fckeditor_php5.php. Therefore, the tip suggested by the author on page 293 to remove all the fckeditor.* files except fckeditor_php5.php would mean that the readers loose the fckeditor.php, which contains that required function for the editor to work. The solution to this error is to copy the function FCKeditor_IsCompatibleBrowser within fckeditor.php and paste it at the beginning of fckeditor_php5.php before copying it to the /include directory and renaming it as FCKEditor.php. Thereafter, it is safe to delete all fckeditor.* files from the /js/fckeditor subdirectory. Check http://dev.fckeditor.net/changeset/2008 for this solution, provided by the FCKeditor development team to this problem. I hope you find this helpful. Best regards, Ramón Bultó |
Thanks for this submission. |
| Chapter 8, page 287. I believe there is an error on the name of the file specified on the header of listing 8-19. The text refers to the file 'left-column.tpl', while the header states 'left-container.tpl'. Obviously, the latter shoud read 'left-column.tpl'. I hope this helps! best regards, Ramón Bultó |
The listing description is incorrect as stated by the user. It should read left-column.tpl |
| Hello, I believe that there is an errata on chapter 7, page 236, listing 7-15. Where it says: $this->title = $this->sanitize($request->getPost('username')); it should say: $this->title = $this->sanitize($request->getPost(title')); Best regards, Ramón Bultó |
User's solution is correct again! |
| Hello, I believe that there is an errata on chapter 7, page 229, listing 7-9. Where it says: <input type="text" id="form_title" name="username" value="{$fp->title|escape}" /> it should say: <input type="text" id="form_title" name="title" value="{$fp->title|escape}" /> I hope this helps! Best regards, Ramón Bultó |
User's solution is correct Thanks once again ;) |
| Hello, On chapter 7, page 224, first paragraph it says: In the constructor CustomerControllerAclManager.php file (located in ./include/Controllers)... and it should say: In the constructor CustomControllerAclManager.php file (located in ./include)... I hope this helps! Best regards, Ramón Bultó |
Provided solution is correct |
| Hello, On Chapter 2, page 22, listing 2-3. I was having problems accessing any page other than the index and I knew that it had something to do with URL redirection. Searching the web and with a little bit of error/trial I was able to make it work on my development machine, which is a Windows XP Professional running Apache 2.0.63 with PHP 5.2.6 and MySQL 5.0.41. I have multiple domains under that configuration, which I don't think it has anything to do with the problem. The contents of the .htaccess file that worked for me are (modified/added lines are marked with ->): RewriteEngine on ->RewriteBase / RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d ->RewriteRule ^(.*)$ index.php I believe the differences with the directives suggested by the book are incorrect, but I can't tell if they would work on a single-domain apache configuration. Thank you. Best regards, Ramón Bultó |
There are many combinations that will work when using mod_rewrite, so if this works for the user I trust that it's correct. The solution in my book works for me, but I've received feedback from different people that it hasn't always worked in their respective environments. |
| Hello, On Chapter 4, page 99. I have detected that when the e-mail is sent to the user just registered, the password is already MD5 encrypted, so there is no way for them to know their real password, thus they can't login. See below a copy a test e-mail I have received: ---------------------------------------------------- Dear Ramon, Thank you for your registration. Your login details are as follows: Login URL: http://www.test.loc/account/login Username: Ramon Password: 6f5cab6f2cea6726b59346be12f215c7 Sincerely, Web Site Administrator ---------------------------------------------------- I'm new to the Zend Engine and I don't really know where I can fix it. Any suggestion would be greatly appreciated. Thank you! Best regards, Ramón Bultó |
I'm not exactly sure what caused this issue for the user, however the code as it stands in the book handles this case. That is, it remembers the non-hashed password so it can be included via email, even though only the md5 hash is stored in the database. |
| Not so much a error, but as something that would be helpful for a PHP Novice, such as myself. In Chapter 2, in writing the index.php file, after the handle is obtained on the Zend_Controller_Front, $controller->throwExceptions should be set to true so that any errors in the scripts can be quickly exposed. This was frustrating for me as there was an error, but I couldn't get any useful information, and didn't know how to debug it. | As the submitter states, not an error but extremely useful. That is, to add $controller->throwExceptions(true); just prior to calling $controller->dispatch() Users should remember to remove this line when implementing the error handling as specified in Chapter 14. |
| Listing 2.2 on page 20, the following line has a typo in the function name: while ($row = mysql_fetch_objects($result)) { It should be while ($row = mysql_fetch_object($result)) { |
This listing does appear on Page 20 but it's not Listing 2.2 (it appears below Figure 2-2) The provided fix is correct. That is, the code should mysql_fetch_object, not mysql_fetch_objects |
| Listing 2-1. Virtual Host Configuration for Apache on Linux (httpd.conf) (Chapter 2, page 16) does not match Listing 2-2. Web Server Configuration for Apache on Windows (httpd.conf) (Chapter 2, page 17) These two listings are different beyond just the file path syntax of the 2 different OS's. |
In Listing 2-2, instead of "AllowOverride None" it should be "AllowOverride All" |
