Setting up DreamWeaver with MySQL PDF Print E-mail

How to connect to your shared hosting account MySQL database connection using Dreamweaver 8.

This tutorial was created in response to a huge outcry of Dreamweaver 8 users wishing to connect to their MySQL database and utilize the interface functionality of dragging and dropping recordsets and server bindings in DW 8.

Connecting through Dreamweaver MX 2004 or 8 to one of disparate configurations of hosting environments can prove to be quite arduous and frustrating. I have been able to connect to 5 different hosting companies, virtual, dedicated and shared.

One of the most common problems is understanding the MySQL structure, and connectivity to databases stored within.


 

First of all, the login and password to a database created with MySQL is completely different than your FTP server login and password. Check with your hosting company if there is a password and login that you must use to connect with MySQL. They may even have a database URL to use that is different than what is explained below (localhost)

Most hosting companies give you access via PLESK or CPanel to manage your databases. I have worked with Globat.com, 1and1.com, Verio.com, ThePlanet.com, Servermatrix.com InMotionHosting.com and DreamHost.com. I have also directly connected to a server at my Institution and was able to navigate through the tables of the databases with Dreamweaver 8.

All of which use PhpMyAdmin to upload and manage databases.

  • HOSTING CAVEAT: The following hosting companies are not DreamWeaver friendly-
    • Godaddy.com hosting - don't even try it. They do not allow a MySQL connection with Dreamweaver
    • Yahoo.com hosting - because of their strange web directory structure and naming conventions; it is almost impossible to figure out what folder your site is located. If you do figure it out, you can connect to Yahoo hosting but use the entry "mysql" instead of "localhost" when setting up your DreamWeaver connection.

Server Scripts:

Our friends at Macromedia have installed some dynamic PHP pages that interact with MySQL in order to force Dreamweaver MX 2004/8 to communicate with the Database while connected via FTP.

These scripts are stored in a subdirectory of your root directory (or any directory that you are storing your PHP Dynamic pages) called _mmServerScripts.

You do not have to create this directory or upload the scripts inside. The scripts inside are:

MMHTTPDB.php & mysql.php

Both of these PHP scripts allow Dreamweaver to make a connection to your MySQL database.

The first one is configured for the computer you are currently working on. It allows the connection from your current IP to the website's IP (or domain name)

If you change computers from home to school or work, you have to delete these scripts from that directory on the web server.

When you create a new connection, a new MMHTTPDB.php files is created that identifies the connection to your current local machine. If you change local computers, then you will receive a connection error when attempting to locate databases in MySQL with Dreamweaver. It will never establish that connection or use the second PHP script which is actually the interpreter/communicator file that talks to the MySQL database.

When you make an attempt to connect to your Database through Dreamweaver, these scripts are uploaded to the base directory detailed in your defined "Site"configuration which we will look at now:

 

 

With regards to the Local Info panel, make sure that you put the proper HTTP address of your website i.e. http://www.fizboo.com

REMOTE CONNECTIONS

 

 

Remote info includes the FTP (domain name) the host directory, where you are putting your files including PHP pages that will be connecting to MySQL.

  • FTP HOST: Students commonly put the name of their hosting company in this field, or they put in ftp.something.com or http or www. For the most part it should be just yourcompany.com i.e.Your Domain Name

Put in your FTP login and password. You can select "Use passive FTP" without any issue in connecting. Test this connection to see if Dreamweaver has made a successful connection.

HOST DIRECTORY

WHERE DO YOUR PHP/HTML Pages live?

Make sure you put the directory, in some cases it's "public_html" this is where your index.html page lives. This directory could be called "www" or "httpdocs" as well. This also know as the web root of your server. It's the folder that Apache has created so that when someone types your URL in a browser, it finds your site's pages.

TESTING SERVER

Change this URL to your Website URL

Select "PHP MySQL" as the server model for your Testing Server configuration.

Then select "FTP" for Access.

Dreamweaver will Auto-populate the remaining fields that you had programmed into the "Remote" configuration.

If you notice the "URL prefix:" window it will have your website address with the directory that you've designated as your documents directory. You need to change this value. This is where most of the connection problems happen when trying to connect to MySQL.

I have http://fizboo.com/htdocs when it should read:

http://www.fizboo.com

(Remember, you put your website address in that field, not my FIZBOO.COM !) For some reason the people at Macromedia think that you need to put your HOST DIRECTORY location here, it's a bug as far as I am concerned.

The reason that this field should only show your actual website address is that those _mmServerScripts live in the web root directory and when you go and connect Dreamweaver to your website, it must "talk" to those scripts that are living in the html documents directory in order to open a line to MySQL on your server.

Save your settings and create or open a PHP page in Dreamweaver 8

File| New| Php

 

CONNECTING TO MYSQL:

Make sure that you have your "Databases" panel open inside of Dreamweaver MX 2004 /8 or hit Cntrl+shift+F10 in Windows.

Click on the "+"symbol to make a new "Connection"

 

The "MySQL Connection" will appear and you select it.

The following panel will open:

Explanation: The "Connection Name" does not have to be the same as your Database name. You can call it anything you wish.

 

"MySQL server:" For most configurations, you can put in "localhost".

The reason being is that Dreamweaver has made a connection to a remote server and treats the remote server as if it were on your machine. There are also other entries for this window, but we will work with just putting in localhost at this time.

If you created login name and password set up for you in MySQL for the database you created with PHPMyAdmin, put them in their respective fields.

Here is one option: You can press "Select" at this time and Dreamweaver will initiate the sequence to connect and communicate with MySQL, any databases that exist on the server will be listed. This will happen after you see Dreamweaver go through several attempts to upload MMHTTPDB.php & mysql.php.

You shouldn't have to add the name before you hit "Select."



If you know the name of the database you created, in this case I created one called "ai" you can insert that in the "Database:" field.

 

If this configuration is proper for your server, then Dreamweaver will connect, and you will see your database appear in the "Databases" panel.

Remember, you can call your connection any name, like I did, but the Database inside of your connection is whatever you created on the server in MySQL.

At this point you can navigate the Tables you created inside of this database.

You should also be able to click on the bindings and start using data from your tables in your PHP document.

 

 

Observe the process of connecting to your server and MySQL. You will see Dreamweaver open the connection in FTP, upload those _MMServerScripts and the show the databases on the machine. If you have a slow connection, this can quite a while and sometimes it will Timeout.

At this time you are directly connected to your database and you can drag and drop all of the fields that you have listed in the table of your database.

Move on to the Tutorials

 

Last Updated on Saturday, 17 November 2007 09:38