As difficult as the choice of which database system to use for your web application is, choosing the right development language to access that database from the web can be even more trying. Fortunately, if you selected MySQL for your database, Dreamweaver MX gives you the power of PHP (Hypertext Preprocessor) for development against that MySQL system out of the box. Although it is possible to use other web development languages with MySQL and it is also possible to use PHP with other database systems, the combination of the two within Dreamweaver MX is quite powerful.
Using Dreamweaver MX, you can take care of the connection from your web application to your MySQL database quickly. In the same way that you start Dreamweaver MX applications with other database systems, you will need to do the following:
Create the site.
Set the document type.
Configure the test server.
Establish the Dreamweaver MX database connection.
Selecting PHP as the document type lets Dreamweaver MX know that you intend to use MySQL as your database platform because that is the only database directly supported within Dreamweaver MX for PHP web application development at this time.
Here, we are concerned with step 4. The basic information required for establishing the connection to your MySQL server instance is as follows:
Given this information, Dreamweaver MX constructs the following code to handle your web application's interaction with the MySQL server.
<?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_WebProjDB = "localhost"; $database_WebProjDB = "WebDB"; $username_WebProjDB = "MyUser"; $password_WebProjDB = "MyPass"; $WebProjDB = mysql_pconnect($hostname_WebProjDB, $username_WebProjDB, $password_WebProjDB) or die(mysql_error()); ?>
Note See Chapter 10 for information about working with the MySQL Connection dialog box in Dreamweaver MX.