PHP & MySQL Everyday
Apps for Dummies
Error Corrections
| Location | In Book | Correction |
|
|
||
| Login App: Pg 115, Listing 4-8, line 17 |
if(isset($_SESSION['$varname'])); Should not have the single quotes. |
if(isset($_SESSION[$varname])); |
|
|
||
| Login
App: Pg 115, Listing 4-8, line 18 |
return
$_SESSION['$varname']; Should not have the single quotes |
return $_SESSION[$varname]; |
|
|
||
| Login
App: Pg 115, Listing 4-8, line 36 |
$_SESSION['$varname']
= $value; Should not have the single quotes |
$_SESSION[$varname] = $value; |
|
|
||
| Online
Catalog App: Pg 143, Listing 5-4, line 25 |
Correct
in book. Not the same in catalog_product_page.inc on the CD. On
CD: echo "<td align='right'> {$products[$i]['food_id']}</td>"; Wrong field name--food_id |
Correct
the line in the program on the CD to match the line in the book. echo "<td align='right'> {$products[$i]['catalog_number']}</td>"; |
|
|
||
| Online
Catalog App: Pg 143, Listing 5-4, line 43-44 |
Correct
in book. Not the same in catalog_product_page.inc on the CD. On
CD, there are 3 extra lines between line 43 and 44: echo "n=$n_per_page<br>"; echo "nend=$n_end<br>"; echo "nprod=$n_products<br>"; Troubleshooting lines should have been removed from the program. |
Correct in book. Remove the 3 extra lines from the program on the CD. |
|
|
||
| Shopping
Cart: Pg 180, Listing 6-6. Line 15 |
echo "<table
border = '0' style='width: 100%'\n"; Missing closing > |
echo "<table border = '0' style='width: 100%'>\n"; |
|
|
||
| CMS: Pg 240-2 |
SQL statements
for this app work only for MySQL 4.1 or later. SERIAL does not exist prior to 4.1. INSERT must be INSERT INTO. INTO is not optional until 4.1. |
If
you are using MySQL 4.0 or earlier, do not use syntax that is only
valid in 4.1 or later.
Use BIGINT UNSIGNED NOT NULL AUTO_INCREMENT instead of SERIAL. |
|
|
||
| CMS: pg 241 |
Correct in book. Not the same in cms.ddl on the CD. create_date is defined in two places--for table Content and for table Dept_User. These two lines are incorrect in the program on the CD. | Change creation_date to create_date on two lines. |
|
|
||
| CMS: pg 247 Listing 7-1 |
The lines
in the book are correct. The program on the CD is not the same
as shown in the book.
Lines 33, 192, 193 are incorrect in the program on the CD. |
Correct the lines in the program on the CD to match the lines in the book. |
|
|
||
| CMS: Page 293 |
The Login-OO.php
program calls and uses Session.class, which was built in Chapter
4 for the Login app. Therefore, the Session.class file in the CMS/OO
directory has the errors discussed above for Listing 4-8. |
Remove the single quotes (') around $varname on lines 17, 18, and 36, as shown above for listing 4-8. |
|
|
||
| CMS: Session class file Line 47 |
The Login-OO.php program uses Session.class, which was built in
Chapter 4 for the Login app. A line needs to be changed in the
Session class when it is used in the CMS app. This change is not
in the Session.class file on the CD nor discussed in the chapter.
The incorrect line is:
$this->storeVariable("auth","yes"); It sets the wrong variable. |
Replace line 47 in Session.class with the following two lines
:
$this->storeVariable("user_name",$acct->getUserId()); $this->storeVariable("user_dept",$acct->getDeptId()); |
|
|
||
| CMS: Account class file |
The Login-OO.php program uses Account.class, which was built in Chapter 3 for the Login app and changed in Chapter 4. Additional changes are required when it is used in the CMS App. These changes are not in the Session.class file on the CD nor discussed in the chapter. The required changes are shown in the next 4 error entries. | Change Account.class as shown in the next four error descriptions. |
|
|
||
| CMS: Account class file Line 10 |
A line needs to be added to Account.class following line 9. |
Add the following line between line 9 and 10, as shown:
private $userID = NULL; private $deptID = NULL; private $cxn; |
|
|
||
| CMS Account class file Line 43 |
$sql = "SELECT
user_name FROM $this->table_name Needs an additional column name |
$sql = "SELECT user_name, dept_id FROM $this->table_name |
|
|
||
| CMS Account class file Line 60-61 |
Two lines need to be added to Account.class after the current
line 59:
$this->userID = $userID; |
Add two lines as shown below:
$this->userID = $userID; $row = $result->fetch_assoc(); $this->deptID = $row['dept_id']; |
|
|
||
| CMS: Account class file End of file |
Two additional methods need to be added to Account.class, at the end of the file, before the closing } and ?>. |
Add
the following two functions so that the end of the file looks as
follows:
function getDeptID()} ?> |