Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The next step after making sure that our database has been installed within MySQL. And we added four more tables, so our Scuba2u database now has five database tables within it. What we need to do is tell PHP where that database is located. And we can set that all up from right within Dreamweaver. I want to make sure that your web server and your database is running. So, you should have the words running, highlighted in green within XAMPP or the Mac side, both your web server and database lights are green. The assumption for every movie from this point on in the course is that both of these are turned on.
I won't be reminding you every movie to do so. So, lets go out to Dreamweaver. We have our Scuba2u website set up. What we now need to do is install another folder in our site structure called Connections, but Dreamweaver creates that for us. We're not going to do anything within the Files panel ourselves. How do we set up that connection between PHP and our database? We want to go out to the Database's tab within Dreamweaver.
Now, in case this tab is not open. We can go over to the Window menu and Server Behaviors, Bindings, and Databases, these three tabs are all located together. So, if you open any one of these three using the Window menu, all three are open at the same time. So, the one we want to choose is the Databases panel. Now, if I don't have a page open, you can see that panel's grayed out, my Insert bar is also grayed out. So, you do need to have a PHP page open.
It doesn't matter which page that is. It can even be a brand new one. So, I'm going to create a brand new PHP page. I just clicked that PHP in the green welcome screen. And it activated my panel. Now, you also want to make sure you have three check marks in here. If for some reason, you do not have three, you can use this Refresh button. And if you do not still have the testing server, click the word Testing Server, and it takes you out to your site area.
As long as you have a green check mark within the server's area and you have a green check mark on each of these, you should be able to click Save. And that will refresh this panel, in case the Refresh button was not enough. If you have a red mark right here, what you need to do is go back to the servers area, and make sure your Testing Server is set up. I will click Save. As long as these three have a check mark in front of them, your plus sign will be active.
I will click the plus sign and choose MySQL connection. We are going to let Dreamweaver create this file for us. So, within the connection name, you can really name this anything you want. I'm going to go by the naming convention of putting conn_ in front of it, showing that it is a connection. And I'm going to call this Log In. Now, we're working with everything in the default version.
So, the MySQL server we're working in is local host. Under user name, I did not create a separate user, other than the basic user within MySQL. This is not how you want to run it on the production side. You would certainly want to create a separate user for MySQL and given them specific permissions. We're not going to worry about that in our development environment. So, the basic XAMPP and MAMP installs. Setup the user name as (UNKNOWN) There is no password for the database, and that is the area where you would not want to work as a (UNKNOWN) user and have no password in a production environment.
However, maintain to your servers would setup a separate user for you or for the websites specifically, to be able to access the database. But for now, (UNKNOWN) goes in here, nothing in password. I will click the Select button to choose the database I want to connect to. Once I do this, every database that shows up in your PHP My Admin area is available to you here. So, we're going to choose the Scuba2u database.
I will click OK. And it's always a good idea to test. Now, when you test this. Dreamweaver is reminding you that in a production environment, you don't want to have an open (UNKNOWN) user with no password. So, this is just a reminder, Dreamweaver's trying to protect your database and assist you. I'll say OK. I know there's no password, but I'm going to use it this way, just for development.
I will click OK. We now have our database within the Dreamweaver panel. And if I open up tables, I have five tables listed. Now, if, for some reason, yours is not showing. Click the Refresh button in the top right. But here are our tables. Within the country table, I have two fields. Fields are columns in a database. Within our log in area, I have information about our users that are allowed to log in.
So, I can not only see the exact tables. But I can see the different fields. How many characters they allow. What type of characters they allow. And the other piece is if I right-click the table name, I can view the data within the table. So, here is the information. These are the people who are allowed to log into our website and the role where you have access to. Now, what I mean by role is we're going to be creating in an administrator website area.
And only the admin role will have access to that part of our website. Anybody who's a guest is not allowed into that admin area. We have just setup the connection within Dreamweaver. We now have a connections folder. Inside of that, it is a PHP file with the name of our connection. And if we open that file and take a look at it, you'll see it's just a listing of how to connect to the database.
Now, this is a file I tend to leave alone. So, I'm just going to close it up. But this file and this folder must be on our web server, in order for PHP to connect to the database. Now, if you do end up changing the log in information in your production area, because right now, we are route with no password, you simply open this file and fix that information. And that will take care of your connection.
So, that is how we connect to database using Dreamweaver. PHP can now communicate with the database. And within the Databases tab, we can view our Database information, including the data within the Database.
Get unlimited access to all courses for just $25/month.Become a member