Specifications

Implementing the Database
As we mentioned earlier, we have made some minor modifications to the Book-O-Rama data-
base presented in Part II.
The SQL to create the book_sc database is shown in Listing 25.1.
LISTING 25.1 book_sc.sqlSQL to Create the book_sc Database
create database book_sc;
use book_sc;
create table customers
(
customerid int unsigned not null auto_increment primary key,
name char(40) not null,
address char(40) not null,
city char(20) not null,
state char(20),
zip char(10),
country char(20) not null
);
create table orders
(
Building Practical PHP and MySQL Projects
P
ART V
546
There is a lot of code in this application. Much of it implements functionality we have
looked at already (particularly in the last chapter), such as storing data to and retriev-
ing it from the database, and authenticating the administrative user. We will look
very briefly at this code, but spend most of our time on the shopping cart functions.
For the code in this project to work as written, you will need to have magic quotes
switched on. If you have not done this, you will need to
addslashes() to data going
to the MySQL database, and
stripslashes() from data coming back from the data-
base. We have used this as a useful shortcut.
You can enable magic quotes on a per-directory basis in an .htaccess file with the
directive
php_value magic_quotes_gpc on (for PHP 4)
or
php3_magic_quotes_gpc on (for PHP 3)
NOTE
31 7842 CH25 3/6/01 3:38 PM Page 546