PHP/MySQL Web Development Using Dreamweaver

MySQL connections

Once you've got your Dreamweaver site defined your next step is to create a connection to your MySQL database. Normally you will do this one per project.

Exercise 3a

  1. Before we can create the MySQL connection, we need to have an open PHP document in Dreamweaver. From the "File" menu, click "New..." and then select "Dynamic page" and "PHP." Click the "Create" button to finish.
  2. Next pull down the "Window" menu. If the "Databases" option is not already checked, then select it.
  3. Look on the right side of the screen for the "Application" window pane. It has a "Databases" tab on it. Click the tab to bring the Databases window to the front.
  4. Click and hold the + sign to add a new database connection. Pull down to highlight the words "MySQL Connection" and let the mouse button go.
  5. In the dialog box that opens up, supply the following information:
    • Connection name: DWphpClass
    • MySQL server: :/home/apache/mysql/data/mysql.sock
    • User name: yournetid
    • Password: the password you defined for your MySQL database
    • Database: yournetid
  6. Click the "Test" button to test your database connection. It should tell you the connection was made successfully. If not, examine your entries carefully to make sure they match the above and that you are using the correct password.

Watch "exercise 3a demo" to see your instructor do the above steps. (time 1:36)

Exercise 3b

  1. We need to make one final change to our connection file, and we will do it by changing the code by hand. This step is optional in your own web projects, but we need to do it for classroom purposes because it will prevent our class from exceeding the maximum number of allowable concurrent database sessions open on the Webscript server. Look in the "Files" window at the right on your screen for a Connections folder and open it up. Double click the file "DWphpClass.php" and select code view. Change the string "msql_pconnect" to "mysql_connect." We have just changed the code so that it does not create a "persistent" connection.
  2. Close and save the file.
  3. Upload the entire site to the server by click on the top level of the site in the Files window and clicking the blue up-arrow.

Watch "exercise 3b demo" to see how. (time 0:46)

Take me to the next section...

Last updated: 02/20/2006 2:51 PM
©2006. The Trustees of Princeton University.