close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Web development tutorial

Create a PHP database connection

Tutorial created by Team WebAssist

Categories: Dreamweaver, PHP

rating

Creating your database connection in Dreamweaver is the final step in preparing your system for dynamic web development. Once this has been defined, you are ready to start producing dynamic websites. A PHP database connection tells Dreamweaver that the current site is going to create PHP pages and refer to a specific database to store or display data.

This tutorial shows you how to set up a PHP database connection from within Dreamweaver that you can then use for your site.

arrow downWhat you need to start

  1. Dreamweaver
  2. A dynamic site defined in Dreamweaver
    For instructions see Defining a Dynamic Site in Dreamweaver
  3. A MySQL database

arrow downThe Databases Panel

The Databases panel allows you to define database connections for your site. This even gives you the opportunity to preview some of the data in your database once a connection is established.

Adobe removed the Databases panel from Dreamweaver CC so if you are using Dreamweaver CC or newer, you will need to first follow this tutorial.
  1. From the Dreamweaver Window menu, select Databases.


The Databases Panel should now be open.

If the window doesn't appear, it is most likely tucked away in the tool panels along the right-hand side of Dreamweaver

arrow downConnect to your database

Once the databases window is accessible, it's time to make a new connection.

If the databases window is grayed out and inactive, try creating a new, blank PHP page. (File > New...)
  1. In the database dialog, click the Add ( + ) option, then choose MySQL Connection.

    The MySQL Connection window will display.
  2. In the Connection field, enter your connection name.
    For this tutorial we will call our connection 'mysql_tutorial', but the connection name can be whatever you like. Try to keep it descriptive of the database being connected to, as several connections can get confusing to work with.
  3. In the MySQL server field, enter the name of your MySQL Server.
    The MySQL server is the name of the server that hosts MySQL. In most cases, it will be hosted on the same server as your site, and in that case you can enter localhost as the server name.
  4. In the User name field, enter your user name and password.
    User name is the name set up for the specific MySQL server you are connecting to, and Password is the password you defined when creating your database.

    If you don't remember creating a password, you probably weren't asked to do so when setting up your testing server or database. You can leave this field blank, but should go and specify a password for your database later. For testing servers, your User name is probably 'root' as this is the default "SuperUser" for MySQL databases.


  5. In the Database field, enter your database or click Select to choose it from a list.
    You can manually input the database here (including .sql), or click Select, to see a list of databases hosted on the MySQL server.

  6. Click Test to ensure that your database connection is working properly. A confirmation dialog should appear telling you it was succesful.
    If the test was unsuccesful, this could be for a couple reasons:

    1. You entered something wrong in the Connection fields. Check that you entered everything correctly.
    2. Most hosting providers won't let you connect to your live database externally. In this case, your connection will probably be correct, but you won't be able to test it. Simply upload your files to your live server for testing in a browser.


    You will not be able to use your live database when creating dynamic pages using WebAssist products such as DataAssist or eCart. These products need to be able to see your database and the tables within, in order to create the appropriate references. You will need to use your local testing server's database, and then export and import that database to your live server, when pushing your dynamic pages live.


  7. Once everything is entered correctly, click OK.

arrow downConfirm the connection

Dreamweaver creates a Connections folder in your current site. This folder will contain a file that includes the details for accessing your database. If you create additional database connections, a new file will be added to this same folder.

Confirm that this folder exists and contains the new connections file.

arrow downWhat to do next...

Now that your database connection is completely set up, you can now utilize it to create dynamic content for your site. Depending on what you intend to create, you might want to start using one of WebAssist's dynamic Dreamweaver extensions, such as DataAssist, eCart, or SecurityAssist.

With your database connection created, you are now ready to jump right into the Getting Started Guides for any of these products.

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating

Skyrunner428939: 4 Years, 6 Months, 4 Weeks, 1 Day, 9 Hours, 53 Minutes ago

Hello, I read carefully this tutorial and I found some problems in trying to connect mine msql database with dreamweaver. I recieve contanly an 404 error when trying to connect the database. After loosing hours on searching and trying to find out why this fault was appearing I finally found the reason of this error 404. The database could connect because there was a port failure in MAMP port configuration. When installing the MAMP server, the ports were standard set to default apache port:8888 and MYSQL port 8889 instead of to be set to 80 and to 3306. You must click to the button "set to default Apache and MySQL port" to change the standard port selection. From that moment everything was OK.
I think you should catch more specially the attention of the user in this important "changing port address" when installing the MAMP server in the specific tutorial.

rating

shootersolutions: 4 Years, 2 Months, 2 Weeks, 3 Days, 7 Hours, 29 Minutes ago

The first thing you have to do after doing the stuff it says first, is to 1. create in the open panel a .php page, like with create a .php page in dreamweaver.
Then if you are using XAMP on Windows without a password, like me, then you need to do the following:
2. Click on the "+" to get to the MySQL to click on, then localhost is the server, I used "root" for the user, nothing entered for password, and the manually insert the database name - in my case ecommerce for the wa_ecommerce database, (without a password it wouldn't look , and without a database, it wouldn't test)
3. Hit "test" then click on error message: don't panic on the noise, checkbox do not show this again.
4. As long as there is no typos in the manual entering of the database name for PHPMyAdmin for me anyway.

Brenda: 3 Years, 8 Months, 1 Week, 20 Minutes ago

I have Dreamweaver CC, the database feature has been removed. What would you suggest to do to get around this and still create a database for the e-commerce site? I got stuck on the first page of instruction :(

rating

Team WebAssist: 3 Years, 8 Months, 6 Days, 5 Hours, 45 Minutes ago

Follow this tutorial to install the Database Window into CC:
http://www.webassist.com/tutorials/Server-behaviors-for-Dreamweaver-Creative-Cloud

: 3 Years, 3 Months, 5 Days, 10 Hours, 59 Minutes ago

This was very easy to follow. I would like to make a comment for those who are having some issues.
I kept getting an error, so I tried changing things around. After the problem persisted, I went to my hosting company and looked up the database that I created.
When I did this I found out that the database was not the actual url of the website but in a different url provided by the hosting comapny and was refering my site. So, if you are having problems connecting during the test, go to your hosting company and ask where your actual database address is. This is going to solve that issue right away.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.