Chapter 9: Connecting to the Database


Download CD Content

The purpose of this chapter is to explain how a middleware program such as a PHP or ASP script can access a database located on the server, perform insertions, and request information using simple select queries. This chapter will also address common problems and demonstrate debugging techniques. The next chapter will continue with more complex examples.

Background

To understand the significance of the material covered in this chapter, you need to recall what middleware—that is, PHP or ASP/JavaScript—programs are; namely, programs running on the server computer in response to a request from a client computer. The server software makes the determination that the file is not a regular HTML file, but instead a PHP or ASP file. This leads to the file being interpreted by the PHP or ASP interpreter, again part of the server support system. The challenge for the interpreter that is covered in this chapter is how to do something other than just interpret PHP and ASP; namely, access (read from and write to) a database. The middleware program has to perform the same operations on a database that are done by the database management system (DBMS) in the stand-alone mode described in the previous chapter. The way the middleware program accomplishes the task is by making a connection to what is called the driver of the DBMS, namely MySQL or Access. This allows the DBMS functions to be invoked under program control to do SQL queries.

This chapter will cover how you can write PHP or ASP scripts to make these connections, and how you write the code to compose SQL statements and pass them to the DBMS. You have read about SQL and practiced writing SQL statements “on paper.” You have also written them in command mode to access MySQL. You have done the equivalent of making SQL statements using the graphical user interface of Access. Now you will create SQL statements as character strings. These character strings will be arguments for PHP functions or ASP methods.




Creating Database Web Applications with PHP and ASP
Creating Database Web Applications with PHP and ASP (Charles River Media Internet & Web Design)
ISBN: 1584502649
EAN: 2147483647
Year: 2005
Pages: 125
Authors: Jeanine Meyer

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net