Page 424 - Beginning PHP 5.3
P. 424
Part III: Using PHP in Practice
Figure 13 - 1 shows you an example of the member list generated by the application.
Figure 13-1
Creating the config.php File
The first application file you ’ re going to create is a very simple one. It contains a list of constants that
configure the application.
Save the following code as config.php . You might want to create a new folder in your document root
called book_club , and save the file in there. You ’ re going to create quite a few files for this application,
and they ’ ll be easier to find if they ’ re all in one folder.
< ?php
define( “DB_DSN”, “mysql:dbname=mydatabase” );
define( “DB_USERNAME”, “root” );
define( “DB_PASSWORD”, “mypass” );
define( “PAGE_SIZE”, 5 );
define( “TBL_MEMBERS”, “members” );
define( “TBL_ACCESS_LOG”, “accessLog” );
? >
As you can see, config.php ’ s job is simply to set up various constants that affect how the application
works:
❑ DB_DSN defines the DSN that is used to connect to the MySQL database
❑ DB_USERNAME holds the MySQL username to use when connecting to the database
❑ DB_PASSWORD stores the MySQL password to use. Don ’ t forget to change “ mypass ” to your real
MySQL root password
386
9/21/09 9:12:02 AM
c13.indd 386 9/21/09 9:12:02 AM
c13.indd 386