PHP 5/MySQL Programming- P73:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 338 PHP 5 MySQL Programming for the Absolute Beginner This chapter details the process of connecting to an MySQL database. If you re using SQLite instead please see appendix B on the CD for how to modify this chapter s code to work with that alternate database. The concepts remain exactly the same but some details change. Getting a Connection The first job is to get a connection between your PHP program and your MySQL server. You can connect to any server you have permission to use. The mysql_connect function arranges the communication link between MySQL and PHP. Here s the connect statement from the showHero program conn mysql_connect localhost The mysql_connect function requires three parameters Server name. The server name is the name or URL of the MySQL server you wish to connect to. This is localhost if your PHP and MySQL servers reside on the same machine which is frequently the case. Username. The username in MySQL. Most database packages have user accounts. Password. The password associated with the MySQL user identified by username. You will probably have to change the username and password fields if you are run. ning this code on a server somewhere. I used default values that work fine on an . . . isolated test server but you must change to your username and password if you try this code on a production server. You can use the same username and password you use to log into MySQL and your program will have all the same access you do. Of course you may want more-restricted access for your programs. Create a special account which has only the appropriate permissions for program users. The mysql_connect function returns an integer referring to the database connection. You can think of this identifier much like the file pointers you learned in chapter 6 Working with Files. The data connection should be stored in a variable I usually use something like conn because many of the other database functions need to access the connection. In the Real World Database .