5 Replies Latest reply on Jul 25, 2012 5:17 AM by ssj111mike

    PHP pages not displaying on Remote/Web server




      Be gentle, DW faithful. I'm a n00b to this entire field and use of PHP, DW, etc. I have a few questions....I'm using ~2008 Macbook Pro, DW5, and MAMP.


      Set up my site with PHP files, got a local test up and running, got the Recordsets/Queries to look and function the way I like off my local server. In other words, the site workds great locally. Signed up for bluehost to act as my remote , uploaded all the files fine. BUT, when I went to view my site on the remote server, the php pages that are restricted to members just don't display at all (HTTP 500 error). I'm assuming it's not a coding error as the pages display properly on the local, but not the remote (therefore, a DB connection issue). Here's what I've done to try and remedy.


      • Exported DB from local, Imported to Remote (so its structured/named the exact same aside from the host-insterted characters before it)
      • Enabled my IP to update the site remotely from host cPanel (my C-Class?)


      The first line of PHP code on all of these member restricted pages starts with:


      <?php require_once('../Connections/TBO_Golf.php'); ?>


      The 'TBO_Golf.php' contains:



      #  FileName="Connection_php_mysql.htm"

      #  Type="MYSQL"

      #  HTTP="true"

      $hostname_TBO_Golf = "localhost";

      $database_TBO_Golf = "TBO_Golf"

      $username_TBO_Golf = " **** "

      $password_TBO_Golf = " **** "

      $TBO_Golf = mysql_pconnect($hostname_TBO_Golf, $username_TBO_Golf, $password_TBO_Golf) or trigger_error(mysql_error(),E_USER_ERROR);



      Question 1) - I'm pretty sure that with the files on the remote server, they run the script trying to connect to a 'localhost', which is causing my error. Do I change the settings in the connection file or in the database connection window to what will work for my remote server? I know what they are as I created a second database connection to the remote (so now I have one for local and remote) Do I have to "re-do" the queries using a connection to the remote?


      Question 2) Is changing the settings like this the best practice when moving from locally proven to remote (and from remote to local for testing) with respect to displaying dynamic pages? If not, what is?


      Question 3) In my attempt to research, I read somewhere that DW can't handle more than one database connection at a time. I find this hard to believe, so is there any truth to this?


      If anyone can help, this will be greatly appreciated!!!


      Thanks in advance!!

        • 1. Re: PHP pages not displaying on Remote/Web server
          Ben M Adobe Community Professional

          1.  Localhost is a common connection in shared hosting environments.  You can double check with Bluehost, but I believe they use localhost.


          2.  Not 100% sure what you are asking here. 


          3.  DW can handle multiple database connections, but why do you need to connect to multiple databases?  This is more a question of database design then it is about the data.


          To go back to your original issue, a 500 error can be a result of a few causes.  One is bad htaccess file so if you are doing rewriting of URLs check that.  Also, check your error logs on the server (your host can tell you the location) and that can shed some light on what is causing the 500 error.

          • 2. Re: PHP pages not displaying on Remote/Web server
            ssj111mike Level 1



            Thanks for the response. Very much appreciated!


            1) Based on your response, looks like I just keep the server name as local host, but just change the username and pword to match my remote user profiles?


            2) Re-reading this question, I guess I'm wondering what are some good practices when transitioning from local to remote? I would assume things like keeping username/pw for local, remote the same, using import/export the same. But I was more focused on the transfer of the DB connections that function on local to the remote. I'm finding that its not as simple as just transferring the site, importing/exporting the DB.


            3) Sorry, wasn't clear on what I meant by multiple databases. It was in reference to connecting to both the local and the remote. This would be in the 'Database' window. So then I could run RS against either DB?


            Thanks for the direction on the error log. I think I know where it is on the cPanel, so hopefully that will shed some light on the issue.


            A final question...When I am testing the site locally and running recordsets off the local db, when I publish to remote, do I have to rewrite the record sets to reference the remote db? ?Or do I just change the DB connection information to access the remote as opposed to the local?



            Thanks for your patience!

            • 3. Re: PHP pages not displaying on Remote/Web server
              Rob Hecker2 Most Valuable Participant

              Firstly, you may not realize it but Dreamweaver has you using the ancient mysql extension, which NO ONE SHOULD EVER USE ANY LONGER. Use the Mysqli extension or PDO. However, it makes sense to go ahead and verify that you CAN connect to the external DB first. In other words, solving problem 1. And for this issue, I don't have any suggestions.


              2. Typically you have a file outside your web root (looks like you've done that ...Connections) that provides the database log-in. This file can be very different on the local system from the external system, but as long as they use the same file name, you don't have to keep track of them. One thing I do is set verbose error messages on for the local system and no error messages for the external system.


              3. Be aware that there is a security issue when doing this. Normally you don't want to let your external DB connect outside the server through http. Your webhost may not even allow it.  In cPanel, see if you have an option for REMOTE MYSQL. You can enter the ip address of your internet connection here to allow the DB to communicate with your local system.


              I don't use the DW database tools just because I prefer to write all my own code and do things my way, so I don't know if you can do this through the DW database tools. But what I do is simply export the external database (as SQL) and replace the local DB with it. This allow you to make changes to both structure and data without being concerned that you are going to mess up your live database.

              • 4. Re: PHP pages not displaying on Remote/Web server
                ssj111mike Level 1

                With the direction given by SnakeEyez02, I was able to solve my issues. Going to get very detailed here....


                I was somewhat stuck because I couldn't understand that when you create the site locally, how do you get it to work online. When I created the DB locally and had usernames and pwords to access, it worked fine. I thought that I could 'preview' the remote site in dreamweaver, which can be done, but takes a bit of work around (create new DB connection, add your IP to remote access list, etc). So I was stuck trying to 'preview' my site on my machine, which won't happen because the hostname should be 'localhost' even on the remote. This is because the website AND db are running on 'localhost' because my host (Bluehost) runs off 'localhost'. So I could never 'preview' the remote site due to the db running "locally" on the remote.


                With Bluehost, they automatically change a few things:


                1. Bluehost places certain characters in front of any username and the database. So when I export from local and import to remote, my DB went from "TBO_Golf" on the local to "(Bluehost characters)_TBO_Golf" on the remote.
                2. The username and pword combo I was using on my local test had to be changed to match my remote credentials. Bluehost limits the amount of characters on usernames and places specific characters in front of any username. So I had to change it from "(Local username)" to "(bluehost inserted characters)_(username)" and matching password. I could have left it and it would have worked, but every time I wanted to update, I would have to change the username/pword combo every time I went from local to remote and vice versa. So I'd rather save myself the headache and just change the local to match.
                3. So, when I uploaded the site to the remote, the only thing I had to do was update the DB name. I went to the website and 'TA-DA!!!' My dynamic pages now work!



                Thanks so much to SnakeEyez02 and Rob Hecker2 for their help!

                • 5. Re: PHP pages not displaying on Remote/Web server
                  ssj111mike Level 1



                  Any suggestions as to where to go to get some more knowledge on using a more up to date mysql connection?