Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once you have deployed your database to a remote server, you can configure your Dreamweaver site so that when it's running locally, it's talking to the local database, and when it's working on the remote site, it's working with the remote database. To do this, you'll have to make some customizations to your connections file. In my web site, it's called explorecalifornia.php, and these files are always located in the Connections folder, under the site root. In the connections file, there are four variables being set: the hostname, the database name, the username, and the password.
These settings currently are for the local database. Using a little bit of PHP conditional code, you can detect where you are running, and set the variables accordingly. I will start in this demonstration by doing little bit of debugging and showing you some values that you can inspect to find out where you are running. I will use an echo command, and I will output to values concatenated together. The first is $_SERVER HTTP HOST. This returns the name of the domain that's accepting and processing the request.
Then I will put in a dot for concatenation, and then I will output $_SERVER bracket REQUEST_URI. This is the full name of the page, as it's known to the browser. Now I will save the changes and run the page in the browser and show you that it returns the name of the domain, in this case local host, and then the full URI, or Uniform Resource Identifier. That includes all of the folders and the file name that's being requested.
In this case, my local server is running in the folder dwwithphp. Now let's see what happens when I am working on the remote server. I will go back to Dreamweaver, and I will go to the Files panel to the Connections folder, and I will put this file onto my server. Then I will go back to the browser, and I will replace the name with the folder that I am using as my local server with the name of folder I am using as the remote server, remote, and I will see that the same file returns a value of remote.
So for this demonstration, I am going to look for the word "remote," and if I find it, I will determine that I am on a remote server. When you are working with an actual remote site, look for your domain name, or your IP Address, because if that value is a part of this string, that tells you are working on the remote site. Here is the PHP code I'll use to do the detection. I will change this line of code, so that instead of echoing this value, I will save this value as a variable. I will call it requesturi.
Then I will create a variable called pos, standing for position, and I will get the value of that variable by calling a function called strpos. The strpos function looks for a substring within a string. In the syntax example, you will see that PHP refers to this as finding a needle in a haystack. So the first value I will pass in is the haystack, my variable requesturi, and then the second value I will pass in is remote and again, if you are working within actual remote site, it might be mycompany.com, the domain name.
The strpos function returns the numeric position of the string that it finds. Or if it doesn't find anything, it returns a blank value. You can determine whether the string was found in the requesturi by asking whether to pos variable returns true or false. So I am going add an if clause. I will create the if statement with a pair of parentheses and an else statement, also with a pair of parentheses. Then I will take the four variables that are being set.
I will cut them to the clipboard, and I will paste them twice into both the if clause and into the else clause. Now I will apply a condition. For the if clause, I will place the cursor between the parentheses, and I will simply type in the name of the variable, pos. This expression will return true if the value was found and false if it wasn't. So the first condition is for the remote site, not for the local, and I am going to change the name of the database from explorecalifornia to exploreremote. And again, if you are working on an actual remote site, you would change all of these values: the hostname, the database name, the username, and the password.
In my case, all of the values are the same except for the database itself. I will save my changes, and I will go to my site header, and I will synchronize. This time I am going to click the Synchronize button in the toolbar, just to show you that that's an available workflow. I will preview files that need to be put onto the remote server, and I will see that my connections file is eligible. I will click OK, and that places the new version of the file on the remote server.
Now I am going to open the file in the Explorers folder, explorerlist.php. You may remember that the difference that I created between the local database and the remote database is that I removed all the data from the explorers table. So I will open explorerlist.php, and I will run it in the browser. So right now, I am looking at the login form for the local site. I will login with User Name explorerone and the Password, which is simply password, and when I look at the version of the list page on the local site, I see all of the data.
Now I will go to the web address in the browser, and I will change from the local site, dwwithphp, to the remote site in the remote folder. If you are prompted to log in again, do so. But then you should see the version of the page on the remote site that shows that there is nothing in the database, that is that the explorers table is empty. And that verifies that you are looking at the version of the database that's targeted for the remote site. When you customize your connections file, you should be aware that it may cause some problems for Dreamweaver.
For example, if I now go to the Databases panel and refresh, depending on the state of your setup, you may or may not be able to see the list of tables, and you may or may not be able to add new server behaviors. If you have any trouble with this, I recommend keeping a couple of different copies of your connections file around, and just rename them as needed when you are doing your development work. In this case, all of my development work is complete, and I am simply deploying my finished PHP site to my remote server, and if I need to make any bug fixes or add simple features to the site later on, I will be able to easily do so using this connections file that's been customized to work with both the local and the remote database.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98677 Viewers
61 Video lessons · 85992 Viewers
71 Video lessons · 69843 Viewers
56 Video lessons · 102133 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.