Setting Up A Php Development Environment For Dreamweaver By Charles Nadeau

  • Uploaded by: Darrell
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Setting Up A Php Development Environment For Dreamweaver By Charles Nadeau as PDF for free.

More details

  • Words: 5,105
  • Pages: 15
Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

Dreamweaver Article Setting up a PHP development environment for Dreamweaver Charles Nadeau Adobe This article describes how to set up a development environment on a Windows or a Macintosh computer that lets you build PHP web applications with Adobe® Dreamweaver® and a MySQL database server. Setting up a development environment for Dreamweaver is a three-part process. First, you set up a PHP application server. Second, you define a Dreamweaver site. Third, you install and connect to your MySQL database. This article follows this three-step process.

Requirements

To complete this tutorial you will need to install the following software and files: Dreamweaver CS3 Try (www.adobe.com/go/devcenter_dw_try/) Buy (www.adobe.com/go/devcenter_dw_buy/) Note: Adobe does not provide technical support for third-party products such as the MySQL database server. Sample files: cafe_php.zip (www.adobe.comhttp://download.macromedia.com/pub/developer/cafe_php.zip) (ZIP, 28K)

Set up a PHP application server (Windows)

To set up a PHP development environment, you must first set up or get access to a PHP application server. An application server is software that helps a web server process web pages containing server-side scripts or tags. When such a page is requested by a browser, the web server hands the page off to the application server for processing before sending the page to the browser. This section describes how to install PHP 5 on your Windows computer. PHP is open source software that you can use for developing, testing, and deploying web applications. For more information, see the PHP documentation at www.php.net/download-docs.php. If you're a Macintosh user, see Set up a PHP application server (Macintosh) (www.adobe.comsetting_up_php_03.html) . This section contains the following topics: Install a web server (www.adobe.com#install_win_iis) Test the web server (www.adobe.com#test_win_iis) Install PHP on your Windows computer (www.adobe.com#install_win_php) Test the PHP server (www.adobe.com#test_win_php) Create a root folder for your application (www.adobe.com#root_win)

Install a web server

First, you need a web server. PHP installs as an extension to an existing web server, enabling the web server to process PHP files. Windows XP Professional users can install and run the Microsoft Internet Information Server (IIS)

1 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

web server on their local computer, as described in this section. Check to see if IIS is installed and running on your system. The way to do this is to look for the C:\Inetpub folder. If it doesn't exist, install IIS as follows. 1. Select Start > Settings > Control Panel > Add or Remove Programs, or Start > Control Panel > Add or Remove Programs. 2. Select Add/Remove Windows Components. 3. Select Internet Information Services (IIS) and click Next. 4. Follow the installation instructions and then test the server as described next.

Test the web server

1. In Dreamweaver or any text editor, create a plain text file called myTestFile.html and enter the following line in the HTML code:

My web server is <em>working.



2. Save the HTML file in the following folder on your computer: C:\Inetpub\wwwroot\ 3. Enter the following URL in your web browser: http://localhost/myTestFile.htm If the browser displays your page and the word "working" is in italics, the web server is running normally. If the page doesn't open as expected, make sure the URL does not contain any errors.

Install PHP on your Windows computer

1. If applicable, log into your Windows system using the Administrator account. 2. In Windows Vista, you must temporarily turn off User Account Control (UAC) before installing PHP or the files will end up in the wrong folder. See this document on the Microsoft site. 3. Download the Windows PHP 5.x installer from the PHP website at www.php.net/downloads.php. The correct download link is "PHP 5.x.x installer" under Windows Binaries. 4. Double-click the installer file you downloaded and follow the onscreen installation instructions. 5. At the Choose Items To Install screen, click the Plus (+) button next to Extensions, locate MySQL in the list, and then select the Will Be Installed On Local Hard Drive option. Many developers use a MySQL database server to build their PHP applications. With PHP 5, however, the MySQL extension that allows PHP to work with a MySQL database server is not installed or enabled by default by the Windows installer. 6. In the PHP installation folder (likely C:\Program Files\PHP), locate the file called php.ini and open it in Notepad. You must edit this file to enable the MySQL extension. 7. Find the following line in the php.ini file:

2 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

;extension=php_mysql.dll

The semicolon (;) at the start of the line tells PHP to ignore the line. 8. Delete the semicolon at the start of the line to enable the extension. extension=php_mysql.dll

9. Save and close the php.ini file. 10. In the PHP installation folder, locate the file called libmysql.dll and copy it to the C:\Windows\system32 folder. This file is required so that IIS can work with PHP 5 and MySQL. 11. Restart IIS by restarting your computer. You can also restart IIS by selecting Start > Control Panel > Administrative Tools, and then double-clicking the Internet Information Services icon to open the IIS console. In the directory tree in the console's left pane, select your default web site and then select Actions > Stop. After a few moments, select Actions > Start. After installing PHP, test the server as described next.

Test the PHP server

1. In Dreamweaver or any text editor, create a plain text file and name it timetest.php. 2. In the file, enter the following code:

This page was created at on the computer running PHP.



This code displays the time when the page was processed on the server. 3. Copy the file to your web server's root folder, C:\Inetpub\wwwroot. 4. In your web browser, enter the URL of your test page, and then press Enter. If PHP is running on your local computer, enter the following URL: http://localhost/timetest.php

The test page should open and display the time of day. The specified time is known as dynamic content because it changes every time you request the page. Click your browser's Refresh button to generate a new page with a different time. If the page doesn't work as expected, check for the following possible errors: The file does not have a .php extension. You typed the page's file path (C:\Inetput\wwwroot\timetest.php) instead of its URL (for example,

3 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

http://localhost/timetest.php) in the browser's address text box. If you type a file path in the browser (as you might be used to doing with normal HTML pages), you bypass the web server and the application server. As a result, your page never gets processed by the server. The URL contains a typing mistake. Check for errors and make sure the filename is not followed by a slash, such as http://localhost/timetest.php/. The page code contains a typing mistake. After successfully installing and testing the server software, create a root folder for your web application as described in the next section.

Create a root folder for your application

You should create a root folder to store all the files of your web application. If IIS is running on your computer, a good place to create the folder is in the Inetpub/wwwroot/ folder, as in the following example: C:\Inetpub\wwwroot\MyWebApp The IIS web server will serve any page in the wwwroot folder or in any of its subfolders in response to an HTTP request from a web browser.

Set up a PHP application server (Macintosh)

To set up a PHP development environment, you must first set up or get access to a PHP application server. An application server is software that helps a web server process web pages containing server-side scripts or tags. When such a page is requested by a browser, the web server hands the page off to the application server for processing before sending the page to the browser. This section describes how to install PHP 5 on your Macintosh computer. PHP is open source software that you can use for developing, testing, and deploying web applications. For more information, see the PHP documentation at www.php.net/download-docs.php. If you're a Windows user, see Set up a PHP application server (Windows) (www.adobe.comsetting_up_php_02.html) . This section contains the following topics: Start the Apache web server (www.adobe.com#install_mac_web) Install PHP on your Macintosh computer (www.adobe.com#install_mac_php) Test the PHP server (www.adobe.com#test_mac_php) Create a root folder for your application (www.adobe.com#root_mac)

Start the Apache web server

First, you need a web server. PHP installs as an extension to an existing web server, enabling the web server to process PHP files. Mac OS X users can use the Apache web server included with their operating system. This section describes how to start the web server, and how to make sure it's working properly. 1. Select Apple > System Preferences > Sharing. 2. Select the Personal Web Sharing option from the Services tab. 3. Click the Start button. 4. In Dreamweaver or any text editor, create a plain text file called myTestFile.html and enter the following line in the HTML code:

4 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

My web server is <em>working.



5. Save the HTML file in the following folder on your computer: /Users/your_user_name/Sites/

where your_user_name is your Macintosh user name. 6. Enter the following URL in your web browser: http://localhost/~your_user_name/myTestFile.html

Note: Make sure to include the tilde (~) character with your user name. If the browser displays your page and the word "working" is in italics, the web server is running normally. If the browser fails to display the page properly, check the URL for errors. Also make sure you prefixed your Macintosh user name with the tilde character.

Install PHP on your Macintosh computer

1. If applicable, log into your Macintosh system using the Administrator account. 2. Create a folder named webapps in your main user folder, Users/your_user_name/webapps. 3. From the Entropy web site at www.entropy.ch/software/macosx/php/, download the PHP for 5.x for Apache 1.3 package (for example, entropy-php-5.2.0-3.tar.gz) and save it in your webapps folder. 4. On your Macintosh, open Terminal (Applications/Utilities) and change the default folder to webapps by typing the following line on the command line and pressing Enter: cd webapps

5. In Terminal, uncompress the gz file by typing gunzip followed by the name of the gz file in your webapps folder. For example, if you downloaded entropy-php-5.2.0-3.tar.gz, enter the following command and press Enter: gunzip entropy-php-5.2.0-3.tar.gz

Note: Do not use Stuffit Expander to uncompress the file. 6. In Terminal, open the tar archive that was uncompressed by typing tar xf followed by the name of the tar file. Example: tar xf entropy-php-5.2.0-3.tar

5 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

An installer package called entropy-php.mpkg is extracted from the archive. 7. Double-click the installer package entropy-php.mpkg and follow the onscreen instructions. After installing PHP, test the application server as described next.

Test the PHP server

1. In Dreamweaver or any text editor, create a plain text file and name it timetest.php. 2. In the file, enter the following code:

This page was created at on the computer running PHP.



This code displays the time the page when was processed on the server. 3. Copy the file to the following folder on your Macintosh: /Users/your_user_name/Sites

The Sites folder is your personal root folder for the Apache web server. 4. In your web browser, enter the following URL and press Return: http://localhost/~your_user_name/timetest.php

The test page should open and display the time of day. The specified time is known as dynamic content because it changes every time you request the page. Click your browser's Refresh button to generate a new page with a different time. If the page doesn't work as expected, check for the following possible errors: The file does not have a .php extension. The URL contains a typing mistake. Check for errors and make sure the filename is not followed by a slash, such as http://localhost/~your_user_name/timetest.php/. Also make sure you included the tilde (~) before your user name. The page code contains a typing mistake. The Apache server is not running. Look in System Preferences, in the Sharing category, to see whether Personal Web Sharing is enabled. After successfully installing and testing the server software, create a root folder for your web application as described in the next section.

Create a root folder for your application

6 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

You should create a root folder to store all the files of your web application. If you're using the Apache web server on your Macintosh, a good place to create the folder is in the Sites folder, as in the following example: /Users/your_user_name/Sites/MyWebApp

The Apache web server will serve any page in the Sites folder or in any of its subfolders in response to an HTTP request from a web browser.

Define a PHP site in Dreamweaver

When you define a PHP site in Dreamweaver, you can specify the location of the site files on your hard disk as well as on a remote server running PHP (for users). You can also specify the method for moving files and folders between the two locations. However, if you're only interested in setting up a personal development environment, and PHP is running on your local computer, then you don't need to specify a remote server for your site. Topics covered in this section: Specify your working folder (www.adobe.com#local) Specify a testing server for Dreamweaver (www.adobe.com#remote) Copy the sample PHP files (www.adobe.com#samples)

Specify your working folder

1. In Dreamweaver, select Site > Manage Sites. In the Manage Sites dialog box, click the New button, and then select Site. The Site Definition dialog box appears. 2. If the Basic tab is showing, click the Advanced tab. 3. In the Site Name text box, enter a name for your web application, such as "Web app tutorial." The name identifies the project in Dreamweaver. 4. Click the folder icon next to the Local Root Folder text box and browse to the root folder you created for your application in the previous section of this tutorial, Create a root folder for your application (www.adobe.comsetting_up_php_04.html#local) , (anchor link to the section above) and then click Select. If you used the suggestion in this tutorial, then the folder is a follows: Windows - \Inetpub\wwwroot\MyWebApp Macintosh - /Users/your_user_name/Sites/MyWebApp 5. In the HTTP Address text box, enter the URL you would enter in a web browser to open your web application. For example, if you followed the folder naming suggestions in this tutorial, then the HTTP address is as follows: Windows - http://localhost/MyWebApp/ Macintosh - http://localhost/~your_user_name/MyWebApp/ Note: On the Macintosh, make sure to include the tilde (~) before your user name. Leave the Site Definition dialog box open. You will specify your testing server next.

Specify a testing server for Dreamweaver

7 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

In this section, you specify a testing server that Dreamweaver can use at design time. Because Dreamweaver does not have an internal PHP server, it needs to use an external PHP server to generate and display dynamic content in Design view and to connect to databases while you work. 1. In the advanced Site Definition dialog box, click Testing Server in the Category list. The Testing Server screen appears. 2. Select PHP MySQL from the Server Model pop-up menu. 3. Select Local/Network from the Access pop-up menu. Dreamweaver displays the folder you specified in the Local Info category. Leave the folder unchanged. 4. In the URL Prefix text box, enter the URL you would enter in a web browser to request a page in your web application. To display live data in your pages while you work, Dreamweaver creates a temporary file, copies it to the designated folder on the server, and attempts to request it using the URL prefix. Dreamweaver makes a best guess at the URL prefix based on the information you provided in the Site Definition dialog box. However, the suggested URL prefix may be incorrect. Correct or enter a new URL prefix if the suggestion in Dreamweaver is incorrect. For example, if you followed the folder naming suggestions in this tutorial, then the correct URL prefix is as follows: Windows - http://localhost/MyWebApp/ Macintosh - http://localhost/~your_user_name/MyWebApp/ The URL prefix should always specify a folder, rather than a particular page on the site. Also, be sure to use the same capitalization you used when you created the folder. 5. Click OK to define the site and dismiss the Site Definition dialog box, then click Done to dismiss the Manage Sites dialog box. You can start developing your own PHP web applications in Dreamweaver. The following section describes how to set up the sample PHP files included with this article.

Copy the sample PHP files

If you like, you can copy the sample files included with this article to the working folder on your hard disk. Copying the sample files and connecting to the sample database (described in the following sections) also sets up the files for a follow-up tutorial, Developing a web application (www.adobe.com/go/learn_dw_webapp) , on the Developer Center. 1. Download and unzip the samples file included with this article. 2. Paste the folders and files in the cafe_php folder into the application root folder you specified when defining the Dreamweaver site. Example:

/MyWebApp/ assets/ data/ send.php view.php

The Dreamweaver site is now defined and the sample files installed. The next step is to connect to a MySQL database server.

8 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

Install MySQL on your computer

You can use a MySQL database server running on your computer to develop PHP applications in Dreamweaver. This section describes how to install the MySQL Community Server 5.0 on your Windows or Macintosh computer. MySQL is open source software that you can use for developing and testing web applications. For more information, see the MySQL documentation at http://dev.mysql.com/doc/refman/5.0/en/index.html. Topics covered in this section: Install MySQL in Windows (www.adobe.com#mysql_win) Create the sample database in Windows (www.adobe.com#db_win) Install MySQL on a Macintosh (www.adobe.com#mysql_mac) Create \the sample database on a Macintosh (www.adobe.com#db_mac)

Install MySQL in Windows

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Windows XP computer. Note: The instructions in this section apply to the "Windows Essentials" installer for MySQL 5.0 in Windows XP. For other versions, please see the MySQL documentation for possible differences in the installation procedure. 1. Download the "Windows Essentials (x86)" installer from the Windows Downloads category on the MySQL download page: http://dev.mysql.com/downloads/mysql/5.0.html#win32 2. Double-click the MSI file you downloaded and follow the onscreen instructions. Note: Select Typical Install when prompted. 3. When the setup wizard is done, run the configuration wizard by making sure the Configure the MySQL Server Now option is selected on the setup wizard's last page and clicking Finish. Note: If you missed the option in the setup wizard, you can open the configuration wizard by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Server Instance Config Wizard. 4. In the MySQL Server Instance Configuration Wizard, make the following choices: For configuration type, select Detailed Configuration. For server type, select Developer Machine For database usage, select Non-Transactional Database Only. For the number of concurrent connections, select Decision Support(DSS)/OLAP. For networking options, accept the default settings. For the default character set, accept the default setting. For the Windows options, select both options – Install As Windows Service, and Include Bin Directory in Windows Path. For security options, enter a root password and confirm it. 5. Click Execute to configure your database server. Now you can verify that the server is working correctly. 6. Start the MySQL Command Line Client by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Command Line Client.

9 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

7. Enter your password (if any) at the command line, and then press Enter. The MySQL client's command prompt appears, as follows: mysql>

8. To verify that MySQL is running, enter the following line at the MySQL command prompt: SHOW DATABASES;

Note: Make sure to include the semi-colon and then press Enter. If MySQL is working correctly, it should list three databases: information_schema, mysql, and test. The next step is to create a fourth database in MySQL called CafeTownsend and populate it with sample data.

Create the sample database in Windows

1. Locate the the SQL script file, tutorial.sql, in the sample files included with this tutorial and copy it in the bin folder in your MySQL installation folder. For a normal installation, the bin folder is located at the following path: C:\Program Files\MySQL\MySQL Server 5.x\bin\ 2. If not already done, start the MySQL database server. To check to see if it's started, select Start > Control Panel > Administrative Tools, then double-click the Services shortcut. In the Services dialog box, make sure the status of the MySQL item is listed as "Started". If not, select the item, right-click, and select Start. 3. Start the MySQL Command Line Client by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Command Line Client. 4. Enter your password (if any), and then press Enter. The MySQL client's command prompt appears, as follows: mysql>

5. Create a new database by entering the following command at the MySQL prompt: CREATE DATABASE CafeTownsend;

Note: Make sure to end the line with a semi-colon and then press Enter. MySQL creates a new database, but it doesn't contain any tables or records yet. 6. Log out of the MySQL client by entering quit; (with semi-colon) and pressing Enter. 7. Open the Windows command prompt by selecting Start > Run, and typing cmd in the Run dialog box. 8. At the system command prompt, populate the new CafeTownsend database by entering or pasting the

10 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

following commands, pressing Enter at the end of each line: cd \ cd Program Files\MySQL\MySQL Server 5.0\bin mysql -uroot -pPassword CafeTownsend < tutorial.sql

If you specified a username during the MySQL setup, replace root with your username. For example, if your username is devdude, then enter -udevdude. If you didn't specify a username at setup, you must still enter -uroot. Make sure you replace Password with your MySQL password. For example, if your password is Te22y01, then enter -pTe22y01. If you didn't specify a password, omit the -pPassword item completely. This command uses the tutorial.sql file to insert tables and records to the CafeTownsend database. 9. To verify that the CafeTownsend database was populated, start the MySQL Command Line Client again (see step 3) and then enter the following command at the MySQL prompt: SHOW TABLES IN CAFETOWNSEND;

MySQL should list the comments, locations, and region tables as follows:

Figure 1. MySQL showing the comments, locations and region tables After creating the sample database in MySQL, connect to it in Dreamweaver as described in Connect to the database (www.adobe.comsetting_up_php_06.html) .

Install MySQL on a Macintosh

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Macintosh. Note: The instructions in this section apply to the package format (DMG) installer of MySQL 5.0 for the Macintosh. For other versions, please see the readme file that comes with the installer for possible differences in the installation procedure. 1. Download an installer package from the "Mac OS X (package format) downloads" category on the MySQL

11 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

download page: http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg If your Mac has an Intel processor, select the "Mac OS X 10.4 (x86)" package. Otherwise, select the "Mac OS X 10.4 (PowerPC, 32-bit)" package. Double-click the DMG file you downloaded (example, mysql-5.0.41-osx10.4-i686.dmg). Your computer mounts the disk image and displays the contents, which include the installer file (example, mysql-5.0.41-osx10.4-i686.pkg). 2. Double-click the installer file (PKG) and follow the onscreen instructions. If you have an Intel Mac, you may see the following error message in the destination disk selection dialog box: "You cannot install this software on this disk. (null)." If this error occurs, click the Go Back button once to return to the previous screen, and then click Continue to advance to the dialog box again. You should now be able to choose the destination disk. 3. After the installation of the database server is complete, install a button to start and stop the database server by double-clicking the MySQL.prefPane file in the installation disk image, and then following the onscreen instructions. l l ams

s i hT 4. On the Macintosh, open Terminal (in Applications > Utilities) and enter the following instructions at the command line: cd /usr/local/mysql sudo ./bin/mysqld_safe

5. Enter your Macintosh password, if necessary, and press Return. 6. Press Control-Z, then at the command line enter bg and press Return. 7. End the session by pressing Control-D, or enter exit. 8. Start the database server by selecting Apple > System Preferences, then clicking the MySQL button under the Other category of preferences. In the dialog box that appears, click the Start MySQL Server button. Note: To stop the server, click the button again. If you want the database server to start automatically every time you start your Mac, select the Automatically Start option in the dialog box. 9. Start a new Terminal session and enter or paste the following instruction at the command prompt: /usr/local /mysql/bin/mysql -uroot The MySQL command prompt appears: mysql >

10. To verify that MySQL is running, enter the following line at the MySQL command prompt: SHOW DATABASES;

Note: Make sure to include the semi-colon and then press Return. MySQL should list the following databases:

12 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

Figure 2. MySQL listing the databases

The next step is to create a fourth database in MySQL called CafeTownsend and populate it with sample data.

Create the sample database on a Macintosh

1. Locate the the SQL script file, tutorial.sql, in the sample files included with this tutorial and copy it into the Documents folder in your home folder. 2. If not already done, start the MySQL database server by selecting Apple > System Preferences, then clicking the MySQL button under the Other category of preferences. In the dialog box that appears, click the Start MySQL Server button. 3. Start a new Terminal session and enter or paste the following instruction at the command prompt: /usr/local/mysql/bin/mysql -uroot

The MySQL client's command prompt appears, as follows: mysql>

4. Create a new database by entering the following instruction at the MySQL prompt: CREATE DATABASE CafeTownsend;

MySQL creates a new database, but it doesn't contain any tables or records yet. 5. Log out of the MySQL client by entering quit; (with semi-colon) and pressing Return. 6. At the system command prompt, populate the new CafeTownsend database by entering or pasting the following command: /usr/local/mysql/bin/mysql -uroot CafeTownsend < ~/Documents/tutorial.sql

This command uses the tutorial.sql file to insert tables and records to the CafeTownsend database. 7. To verify that the CafeTownsend database was populated, return to the MySQL command line (see step 3) and

13 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

then enter the following command at the MySQL prompt: SHOW TABLES IN CAFETOWNSEND;

MySQL should list the comments, locations, and region tables as follows:

Figure 3. MySQL showing the comments, locations, and region tables

After creating the sample database in MySQL, connect to it in Dreamweaver as described next.

Connect to the database

This section describes how to create a connection in Dreamweaver to the sample Cafe Townsend database. 1. In Dreamweaver, open one of the PHP pages in your site, such as view.php or send.php. 2. In the Databases panel (Window > Databases), click the Plus (+) button on the panel and select MySQL Connection from the pop-up menu. The MySQL Connection dialog box appears. 3. Enter connTownsend as the connection name. 4. In the MySQL Server box, enter localhost. 5. Enter your MySQL user name and password. If you didn't define a user name while configuring your MySQL installation, enter root in the Username text box. If you don't have a password, leave the Password text box blank. 6. In the Database text box, enter CafeTownsend. CafeTownsend is the name of the MySQL database you created. 7. Click Test. Dreamweaver attempts to connect to the database. If the connection fails, do the following: Double-check the server name, user name, and password. Check the settings for the folder Dreamweaver uses to process dynamic pages (see Specify a testing server for Dreamweaver) 8. Click OK. The new connection appears in the Databases panel. Expand the connTownsend connection, and then expand the

14 of 15

9/21/08 2:51 PM

Adobe - Developer Center : Setting up a PHP development environ...

http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php...

Tables branch. The three tables in the database should appear, as follows:

Figure 4. The Databases panel showing the three tables If you want, you can now do the Developing a web application (www.adobe.com/go/learn_dw_webapp) tutorial on the Developer Center. This follow-up tutorial uses the setup described in this tutorial to teach you how to display dynamic content on web pages. The tutorial also shows you how to create a form that saves visitor comments to the database.

Where to go from here

For more articles and tutorials on developing for PHP using Dreamweaver, visit the Dreamweaver Developer Center's web application development page (www.adobe.com/devnet/dreamweaver/application_development.html#php) (www.adobe.com/devnet/dreamweaver/php.html) .

About the author

Charles Nadeau is a documentation manager at Adobe, where he leads the development of end-user content for Dreamweaver and acts as the Web Suite content architect. He also managed the documentation for Flex Builder 1 and 2, Fireworks 8, and the last few releases of Dreamweaver. Charles started at the company by writing the help for Dreamweaver UltraDev 1 and 4 as well as numerous articles and tutorials. Charlesʼ interests include web design and development, motorcycling, and history.

Copyright © 2008 Adobe Systems Incorporated. All rights reserved.

15 of 15

9/21/08 2:51 PM

Related Documents


More Documents from ""