PHP & MySQL Everyday Apps For Dummies Error Corrections

LocationIn BookCorrection
Page 115, Listing 4-8, Line 17 if(isset($_SESSION['$varname']));
Should not have the single quotes
if(isset($_SESSION[$varname]));
Page 115, Listing 4-8, Line 18 return $_SESSION['$varname'];
Should not have the single quotes
return $_SESSION[$varname];
Page 115, Listing 4-8, Line 36 $_SESSION['$varname'] = $value;
Should not have the single quotes
$_SESSION[$varname] = $value;
Page 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>";
Page 143, Listing 5-4, Line 43 Correct in book. On CD, catalog_product_page.inc has 3 extra lines between line 43-44:

echo "n=$n_per_page<br>";
echo "nend=$n_end<br>";
echo "nprod=$n_products<br>";
Troubleshooting lines should have been removed
Page 180, Listing 6-6, Line 15 echo "<table border='0' style='width: 100%'\n";
Missing closing >
echo "<table border='0' style='width: 100%'>\n";
Page 240-2, SQL statements for this app work only for MySQL 4.1 or later.
SERIAL does not exist prioir 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.
Page 241, Correct in book. Not the same in cms.ddl on the CD.
Change creation_date to create_date on two lines, to match the book.
Page 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
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.
Page NA, Session class file, Line 47 The Login-OO.php program uses Session.class, which was built in Chapter 4 for the Login app. A lines needs to be changed in the Session class when it is used in the CMS app. The incorrect line is:
$this->storeVariable("auth","yes");
It sets the wrong variable.
$this->storeVariable("user_dept",$acct->getDeptID());
Page NA, CMS Account class , Line 10 A line needs to be added to Account.class following line 9
lines need to be added
Add the following between lines 9 and 10, as shown:
private $userID=NULL;
private $deptID=NULL;
private $cxn;
Page NA, 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
Page NA, CMS Account class file, Line 60-61 Two lines need to be added to Account.class after the current line 59:
Add two lines
Add two lines as shown below:
$this->userID=$userID;
$row=$result->fetch_assoc();
$this->deptID = $row['dept_id'};
Page NA, 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 ?>
Need to add two methods
Add the following two functions so that the end looks as follows:
function getDeptID()
{
  return $this->deptID;
}

function getUserId()
{
  return $this->userID;
}
}
?>