As a newbie (PHP - version 4.0.4.pl1 and MySQL -version 3.23.26 on RedHat 7.1 are my introduction to both programming and RDBMS - so there is hope!), I have to say that this is the best book on the subject that I have read so far. I have successfully installed the code and used the examples including the winestore site. There are some issues which I hope to address as tips on using this book that may seem trivial or stupid to the initiated. Remember that these tips may be particular to the versions I am using.
1) Follow the instructions on sessions with care and pay attention to the details. For example, an earlier discussion notes the session.name PHPSESSID default ("there is no reason to change unless..." - p.324) in php.ini and then the examples for "Managing Sessions" (Appendix D p.535) requires changing this to PHPSESSION (you must add the table to your winestore db using the example p.528). Go ahead an back up the php.ini file before you alter it.
a) The "bear trap" tip on page 330 is NOT a suggestion. If you do not make certain that register_globals is "Off" in php.ini, you will not acheive the desired results when using the validation script to repopulate the member form after a mistake.
2) There are two db.inc files (the dbdummy.inc files), one for the book examples and one for the winestore application. The difference is that the "examples" version includes the "clean" function. If you altered and copied this "example" version to your /usr/share directory (Suggestion: Create a php directory under /usr/share and add the altered - according to instructions - db.inc file then open php.ini and go to include_path to add =".:/usr/share/php" [for Linux] as the comments suggest syntax - fyi this is where you should put error.inc and include.inc as well if you follow these directions) you need to get rid of the "clean" function when you move on to the winestore application (whose db.inc excludes the function) because it is already provided in include.inc. If you don't do this Browser will say: "Cannot redeclare clean()". If you are Tarzan (like me), this means "you have attempted to define the same function in the same way twice - BOING!"
3) I had problems with "require" on every script that used this (again - "Cannot redeclare ..."). Using require_once (for error.inc, include.inc) solved this problem for me on every script. I don't say it is the optimal solution - it just works (authors?).
4) For error.inc, go ahead and change the "hugh" under the "Send error to the administrator by email" comment to your user name so you can get hugh's hate mail from Apache(just one of those things).
5) The scripts have a few minor mistakes that you will have to debug with the help of your browser. (Sorry I didn't take notes, but it really helped in the learning experience - hey, it builds character!).
There is an issue (two depending upon how you look at it) that I will note. The use of addslashes and stripslashes becomes extremely important in dealing with sessions and the db ("clean" just doesn't cut it), especially if you alter the code and attempt to use special characters in the db. For example, if you put in a name like O'Connor in the member form, you will see the telltale slash in the membership acceptance and order forms, as well as the repopulation for change details on your browser. If you experiment and add a region name with a special character, all hell will break loose with sessions and the search function will not work for the region name (shopping cart - not at all). I am currently trying to solve this problem (help from authors or anybody appreciated).
Although Justin (obviously a mountain man compared to my flatlander experience) was a little harsh on the authors, I am very grateful. I would, however, like to see his comments addressed in the next edition.
|