1 2 3 Previous Next 89 Replies Latest reply: Apr 15, 2014 11:27 AM by osgood_ RSS

    Mysql connection with 1and1.co.uk

    PBrackett12 Community Member

      I am trying to establish a connection with a mysql database at 1and1.co.uk but the connection cannot be established.  I have checked the login details with 1and1 and they have suggested I contact Adobe.  I am a 'design' interface user of Dreamweaver - I don't know code, so any simple suggestions would be gratefully received!

        • 1. Re: Mysql connection with 1and1.co.uk
          osgood_ MVP

          Have you got all the right information which will allow you to connect to a database:

           

          MySQL Host Name
          User Name
          Password
          Database Name

           

          http://faq.1and1.co.uk/web_space__access/mysql/6.html

          • 2. Re: Mysql connection with 1and1.co.uk
            PBrackett12 Community Member

            Yes, I believe I do - certainly I went through the login details with tech support at 1and1 and they confirmed I did.

            • 3. Re: Mysql connection with 1and1.co.uk
              osgood_ MVP

              Once you have the correct information do a connection test by copying the code below pasting it into a new php DW file and inserting the information needed between the "" below. Run the page in a browser and see what message you get.


              <?php

              $hostname="";
              $database="";
              $username="";
              $password="";

              $link = mysql_connect($hostname, $username, $password);
              if (!$link) {
              die('Connection failed: ' . mysql_error());
              }
              else{
                    echo "Connection to MySQL server " .$hostname . " successful!
              " . PHP_EOL;
              }

              $db_selected = mysql_select_db($database, $link);
              if (!$db_selected) {
                   die ('Can\'t select database: ' . mysql_error());
              }
              else {
                   echo 'Database ' . $database . ' successfully selected!';
              }

              mysql_close($link);

              ?>

              • 4. Re: Mysql connection with 1and1.co.uk
                osgood_ MVP

                PBrackett12 wrote:

                 

                Yes, I believe I do - certainly I went through the login details with tech support at 1and1 and they confirmed I did.

                 

                So lets see the php connection file or code you are using NOT the password. DONT post that here.

                • 5. Re: Mysql connection with 1and1.co.uk
                  PBrackett12 Community Member

                  Thanks - how do you mean run it in a browser, do you mean 'live view' or do I need to upload it as a page?

                  • 6. Re: Mysql connection with 1and1.co.uk
                    osgood_ MVP

                    PBrackett12 wrote:

                     

                    Thanks - how do you mean run it in a browser, do you mean 'live view' or do I need to upload it as a page?

                     

                    Upload the page and browse out to it. You may save it as connection_test.php

                    • 7. Re: Mysql connection with 1and1.co.uk
                      PBrackett12 Community Member

                      I received a success message!

                      • 8. Re: Mysql connection with 1and1.co.uk
                        osgood_ MVP

                        PBrackett12 wrote:

                         

                        I received a success message!

                         

                        Great, has that solved your issue?

                        • 9. Re: Mysql connection with 1and1.co.uk
                          PBrackett12 Community Member

                          Unfortunately not - just tried to use the same log in details but into the database fields, ie: Connection name, Mysql server, User name, password, database and again got an error message.  I suspect I'm doing something stupid!

                          • 10. Re: Mysql connection with 1and1.co.uk
                            osgood_ MVP

                            PBrackett12 wrote:

                             

                            Unfortunately not - just tried to use the same log in details but into the database fields, ie: Connection name, Mysql server, User name, password, database and again got an error message.  I suspect I'm doing something stupid!

                             

                            Can you run through step by step what you are doing. Obvioulsy there is no problem with connecting to the database as proved.

                             

                            Not sure what you mean by:

                            'just tried to use the same log in details but into the database fields'

                            • 11. Re: Mysql connection with 1and1.co.uk
                              PBrackett12 Community Member

                              I mean I am entering the details you tested into the above box.  Under Connection name, I am just using the name of the website, under MySQL server I am using the'hostname', I'm using the same username and password and database is also the same as entered into your test.

                               

                              I really appreciate your help with this.

                              • 12. Re: Mysql connection with 1and1.co.uk
                                PBrackett12 Community Member

                                Oh just realised the screen shot I posted didn't come out in this thread.

                                • 13. Re: Mysql connection with 1and1.co.uk
                                  osgood_ MVP

                                  PBrackett12 wrote:

                                   

                                  Oh just realised the screen shot I posted didn't come out in this thread.

                                   

                                  So are you using the server behaviours that ship with Dreamweaver to establish a connection?

                                   

                                  If youre working with php/mysql you should really set up a local testing environment (server) on you own machine, have you done that?

                                  • 14. Re: Mysql connection with 1and1.co.uk
                                    PBrackett12 Community Member

                                    I think it may be the server behaviours that is the problem. When i go to 'manage my site' and enter the site I am working on there is a red star next to the 'server' indicating something is "incomplete".  I did have a test site up and running (using MAMP) but I want to switch it to a remote server to get full functionality, so I deleted the test server.

                                    • 15. Re: Mysql connection with 1and1.co.uk
                                      osgood_ MVP

                                      PBrackett12 wrote:

                                       

                                      I think it may be the server behaviours that is the problem. When i go to 'manage my site' and enter the site I am working on there is a red star next to the 'server' indicating something is "incomplete".  I did have a test site up and running (using MAMP) but I want to switch it to a remote server to get full functionality, so I deleted the test server.

                                       

                                      You need to go back to MAMP. It really is the way to go when producing a dynamic php/mysql site. I use it all the time, I never try to develop anything on a remote server. Once it's all running locally you should encounter very, very few issues once you transfer it across to your remote environment.

                                      • 16. Re: Mysql connection with 1and1.co.uk
                                        PBrackett12 Community Member

                                        Thanks, I have re-established the test server with MAMP.  But I am trying to develop a very simple login function for my website - how do I transition to a remote server if I cannot establish a connection?  Do I require a remote server to enable third parties to login to my site or can I use the MAMP?

                                        • 17. Re: Mysql connection with 1and1.co.uk
                                          osgood_ MVP

                                          PBrackett12 wrote:

                                           

                                          Thanks, I have re-established the test server with MAMP.  But I am trying to develop a very simple login function for my website

                                           

                                          So you have a website folder in your MAMP htdocs folder, which you have defined in Dreamweaver as using php/msql?

                                           

                                          You have used phpMyAdmin to create a database and have a table in the database which contains username and password?

                                           

                                          You have a login.php page and on that page you have login form?

                                           

                                          You connect to the database using the Server Behaviours panel?

                                           

                                          How far have you got in the process above?

                                          • 18. Re: Mysql connection with 1and1.co.uk
                                            PBrackett12 Community Member

                                            I have done all of the above.  So I have a register page that populates the Mysql database and a login page that draws from that and, if successful, directs to another page.  There are a few glitches because I deleted it, but I've re-established the login page successfully.

                                            • 19. Re: Mysql connection with 1and1.co.uk
                                              osgood_ MVP

                                              PBrackett12 wrote:

                                               

                                              I have done all of the above.  So I have a register page that populates the Mysql database and a login page that draws from that and, if successful, directs to another page.  There are a few glitches because I deleted it, but I've re-established the login page successfully.

                                               

                                              Ok so everything is working locally and you want to now transfer this over to your remote server, is that correct?

                                              • 20. Re: Mysql connection with 1and1.co.uk
                                                PBrackett12 Community Member

                                                Yes that is correct.  Well in theory, barring the glitches I need to iron out - but in principle, I would like to know how to transfer across even if I don't do it at the moment.  Thanks for all your help - do you work for Adobe? I'm new to this forum thing!

                                                • 21. Re: Mysql connection with 1and1.co.uk
                                                  osgood_ MVP

                                                  PBrackett12 wrote:

                                                   

                                                  Yes that is correct.  Well in theory, barring the glitches I need to iron out - but in principle, I would like to know how to transfer across even if I don't do it at the moment.

                                                   

                                                  First you need to export the database tables from phpMyAdmin. Once phpMyAdmin is open select the database and then select a table to export. Along the top of the screen select the 'Export' tab. Ignore everything and look for 'Save as file' - tick the box and click 'Go' at the bottom of the screen. Depending on what version of phpMyAdmin you are running the directions above should be very similar. The file should save with a .sql extention.

                                                   

                                                  Once you have the tables exported locally go to your remote control panel where the remote database information is stored and click the phpMyAdmin button (I think I saw this when viewing one of the links earlier in this thread http://faq.1and1.co.uk/web_space__access/mysql/6.html)

                                                   

                                                  Choose 'Import' - browse to the .sql file/s on your local machine and select them. If successful the tables and the data should have been transfered across to your remote database.

                                                   

                                                  Back in your local site folder look for the 'Connections' folder. Duplicate the 'con_blah_blah.php' file and open it. (I duplicate it so I have one for a local connection and one for a remote connection)

                                                   

                                                  Replace your local connection details with your remote connection details:

                                                   

                                                  $hostname_con_blah_blah = "xxxxxx";

                                                  $database_con_blah_blah = "xxxxxx";

                                                  $username_con_blah_blah = "xxxxxx";

                                                  $password_con_blah_blah= "xxxxxxx";

                                                   

                                                   

                                                  That should be it - upload your files and you should be good to go.

                                                  • 22. Re: Mysql connection with 1and1.co.uk
                                                    PBrackett12 Community Member

                                                    Thank you so much for all your help.

                                                    • 23. Re: Mysql connection with 1and1.co.uk
                                                      osgood_ MVP

                                                      PBrackett12 wrote:

                                                       

                                                      Thank you so much for all your help.

                                                       

                                                      Hope it works for you....let us know how you get on.

                                                      • 24. Re: Mysql connection with 1and1.co.uk
                                                        PBrackett12 Community Member

                                                        Sorry, this is probably a very dim question but where does the phpMyAdmin (I'm using MAMP) save the .sql file to?

                                                        • 25. Re: Mysql connection with 1and1.co.uk
                                                          osgood_ MVP

                                                          PBrackett12 wrote:

                                                           

                                                          Sorry, this is probably a very dim question but where does the phpMyAdmin (I'm using MAMP) save the .sql file to?

                                                           

                                                          At the time of exporting the table you should be able to tell phpMyAdmin where you want to save the file. Its like any other file only with a .sql extention. I usually just save to the desktop as its easier to browse to when importing it into the remote version of phpMyAdmin

                                                          • 26. Re: Mysql connection with 1and1.co.uk
                                                            PBrackett12 Community Member

                                                            Me again!  I was able to import the data into my remote server but am continuing to face the same problem with connecting to the remote server.  I now get an error message "MySQL Error 2005 Unknown MySQL Server Listed

                                                             

                                                            Any thoughts?

                                                             

                                                            Thanks

                                                            • 27. Re: Mysql connection with 1and1.co.uk
                                                              osgood_ MVP

                                                              PBrackett12 wrote:

                                                               

                                                              Me again!  I was able to import the data into my remote server but am continuing to face the same problem with connecting to the remote server.  I now get an error message "MySQL Error 2005 Unknown MySQL Server Listed

                                                               

                                                              Any thoughts?

                                                               

                                                              Thanks

                                                               

                                                              Have you got the correct remote server connection details set up in  your 'connection'.php  file in the 'Connections' folder?

                                                              • 28. Re: Mysql connection with 1and1.co.uk
                                                                PBrackett12 Community Member

                                                                I've gone into that folder and there is only a php form for the test server.  Should there be an additional php file for the remote server?  Can I have a local and remote server listed in DW at the same time?

                                                                • 29. Re: Mysql connection with 1and1.co.uk
                                                                  osgood_ MVP

                                                                  PBrackett12 wrote:

                                                                   

                                                                  I've gone into that folder and there is only a php form for the test server.  Should there be an additional php file for the remote server? 

                                                                   

                                                                  When you say form you mean file right?

                                                                   

                                                                  All you do is make a duplicate of the 'connection.php' file which will be in the 'Connections' folder of your local site. Open the file and replace your 'local' connection details with those of your remote connection details. (the details you previously used to make the successful test connection). Upload the duplcate copy (it must be named the same as the original 'connection' file once on the server) So you can either change the name when its uploaded or change it locally before uploading.

                                                                   

                                                                  I keep two 'connection' files one for the 'local' connection and one for the 'remote' connection.

                                                                   

                                                                  I just name them blah_blah.php(local) or blah_blah.php(remote). (blah_blah in his case is the file name generated automatically by Dreamweaver when it creates the 'connection' file, so yours won't be named blah_blah). I just remove (local) from the end of the file when I'm testing locally and remove (remote) from the end of the file once uploaded to the remote server.

                                                                  • 30. Re: Mysql connection with 1and1.co.uk
                                                                    PBrackett12 Community Member

                                                                    Sorry, yes I did mean file.  Still no success.  I think the problem might be that I still have the testing server listed in the settings?  The error I get indicates it is mapping to the localhost still?

                                                                     

                                                                    When I am in a .php file and add a database - the testing database is still showing - should I also delete that before adding the remote database?

                                                                     

                                                                    You can tell I am a complete amateur to this!

                                                                    • 31. Re: Mysql connection with 1and1.co.uk
                                                                      osgood_ MVP

                                                                      PBrackett12 wrote:

                                                                       

                                                                      Sorry, yes I did mean file.  Still no success.  I think the problem might be that I still have the testing server listed in the settings?  The error I get indicates it is mapping to the localhost still?

                                                                       

                                                                      No that would have nothing to do with the problem. Once uploaded to the remote server the pages are independent of any Dreamweaver site settings and should work as standalone files.

                                                                       

                                                                      Let's just take this step by step.

                                                                       

                                                                      1) At the moment everything is running correctly at a local level, you have created a database, can login etc yes?

                                                                       

                                                                      2) You have a remote database and have transfered the local database table/s to the remote database yes?

                                                                       

                                                                      3) You have uploaded all the local files associated with your website to the remote server using the same folder/file structure, yes?

                                                                       

                                                                      if all the above critera has been met then it shoulld really be as simple as changing the 'connection' details in the connection file and uploading it to the remote server in the 'Connections' folder.

                                                                      • 32. Re: Mysql connection with 1and1.co.uk
                                                                        PBrackett12 Community Member

                                                                        Thanks.  The answer to all those points is yes.

                                                                         

                                                                        The only question I have is that the website used to sit in a different location - I moved it when I introduced the local server so that it now resides within /Applications/MAMP/htdocs/Oakfieldstables.  But I did a complete site upload yesterday so the local mapping should mirror the remote mapping if I put the entire site?

                                                                        • 33. Re: Mysql connection with 1and1.co.uk
                                                                          osgood_ MVP

                                                                          Another connection test would be to open the page and comment out the 'connection' line of code using <!--      -->:

                                                                           

                                                                           

                                                                          <!-- <?php require_once('Connections/conXXXXXXXXXX.php'); ?> -->

                                                                           

                                                                          Paste the block of php code below in after the line above: Use the same remote connection details that you used when you previously connected successfully  APART FROM the $database variable which you should copy from the 'connections' file and paste in as below: (marked in red) USE the remote database name NOT the local database name (which will be what you will copy from the local connections file) where the ="XXXXXXX' are. In the following 2 instances (marked in red) just the $variable part is required NOT the ="XXXXX"; part: 

                                                                           

                                                                          <?php

                                                                           

                                                                          $hostname="XXXXXXX";

                                                                          $database_conXXXXXXXXXXXX = "XXXXXXX;

                                                                          $username="XXXXXXXX";

                                                                          $password="XXXXXX";

                                                                           

                                                                          $link = mysql_connect($hostname, $username, $password);

                                                                          if (!$link) {

                                                                          die('Connection failed: ' . mysql_error());

                                                                          }

                                                                          else{

                                                                          echo "Connection to MySQL server " .$hostname . " successful!

                                                                          " . PHP_EOL;

                                                                          }

                                                                           

                                                                          $db_selected = mysql_select_db($database_conXXXXXXXXXXXX, $link);

                                                                          if (!$db_selected) {

                                                                          die ('Can\'t select database: ' . mysql_error());

                                                                          }

                                                                          else {

                                                                          echo 'Database ' . $database_conXXXXXXXXXXXX . ' successfully selected!';

                                                                           

                                                                          }

                                                                           

                                                                          mysql_close($link);

                                                                           

                                                                          ?>

                                                                          • 34. Re: Mysql connection with 1and1.co.uk
                                                                            osgood_ MVP

                                                                            PBrackett12 wrote:

                                                                             

                                                                            Thanks.  The answer to all those points is yes.

                                                                             

                                                                            The only question I have is that the website used to sit in a different location - I moved it when I introduced the local server so that it now resides within /Applications/MAMP/htdocs/Oakfieldstables.  But I did a complete site upload yesterday so the local mapping should mirror the remote mapping if I put the entire site?

                                                                             

                                                                            That all sounds absolutely fine.

                                                                            • 35. Re: Mysql connection with 1and1.co.uk
                                                                              PBrackett12 Community Member

                                                                              I'm sorry I am not sure I follow this.  Should this code go into the connections file?  Does it matter where and do I include that first line as well as the entire piece after your explanatory paragraph?  I'm also a little confused about what I should be putting in the database_conXXX part?  My database is located at dbXXXXXX.db.1and1.com  Should that be what I include?

                                                                              • 36. Re: Mysql connection with 1and1.co.uk
                                                                                osgood_ MVP

                                                                                Let me try and make this a bit easier.

                                                                                 

                                                                                The block of code below should NOT go in your connection.php file it should go at the top of the page where your login form is AFTER the link to the existing connection file. Leave it at the top of the page BUT comment it out <!--  --> like below:

                                                                                 

                                                                                <!-- <?php require_once('Connections/conXXXXXXXXXX.php'); ?> -->

                                                                                 

                                                                                 

                                                                                Use the remote connection username and password details to fill in where the XXXXX are below for $username and $password. Copy the $database_con details line of code from the original connection file (the one we commented out) and paste it where marked in red below. Change the ="XXXXXXX" to the name of your REMOTE database. Where this is - "YourDataBaseName" - in the code just type in between the " " the name of your REMOTE database.

                                                                                 

                                                                                 

                                                                                 

                                                                                <?php

                                                                                $hostname="dbXXXXXX.db.1and1.com";

                                                                                $database_conXXXXXXXXXXXX = "XXXXXXX;

                                                                                $username="XXXXXXXX";

                                                                                $password="XXXXXX";

                                                                                 

                                                                                $link = mysql_connect($hostname, $username, $password);

                                                                                if (!$link) {

                                                                                die('Connection failed: ' . mysql_error());

                                                                                }

                                                                                else{

                                                                                echo "Connection to MySQL server " .$hostname . " successful!

                                                                                " . PHP_EOL;

                                                                                }

                                                                                 

                                                                                $db_selected = mysql_select_db("YourDataBaseName", $link);

                                                                                if (!$db_selected) {

                                                                                die ('Can\'t select database: ' . mysql_error());

                                                                                }

                                                                                 

                                                                                mysql_close($link);

                                                                                 

                                                                                ?>

                                                                                • 37. Re: Mysql connection with 1and1.co.uk
                                                                                  PBrackett12 Community Member

                                                                                  Ok, I think I did what I was supposed to do - although I got a bit lost.  But the result was the following when I uploaded it:  Parse error: syntax error, unexpected '=' in /homepages/41/d259550773/htdocs/oakfieldstables/login.php on line 6

                                                                                   

                                                                                  For the sake of clarity I've provided the code:

                                                                                   

                                                                                  <!-- <?php require_once('Connections/Testserver.php'); ?> -->

                                                                                  <?php

                                                                                   

                                                                                  $hostname="dbXXXX.db.1and1.com";

                                                                                   

                                                                                  $database_conTestserver.php = "dbXXXX";

                                                                                   

                                                                                  $username="dboXXXX";

                                                                                   

                                                                                  $password="XXXX";

                                                                                   

                                                                                   

                                                                                   

                                                                                  $link = mysql_connect($hostname, $username, $password);

                                                                                   

                                                                                  if (!$link) {

                                                                                   

                                                                                  die('Connection failed: ' . mysql_error());

                                                                                   

                                                                                  }

                                                                                   

                                                                                  else{

                                                                                   

                                                                                  echo "Connection to MySQL server " .$hostname . " successful!

                                                                                   

                                                                                  " . PHP_EOL;

                                                                                   

                                                                                  }

                                                                                   

                                                                                   

                                                                                   

                                                                                  $db_selected = mysql_select_db("dbXXXX", $link);

                                                                                   

                                                                                  if (!$db_selected) {

                                                                                   

                                                                                  die ('Can\'t select database: ' . mysql_error());

                                                                                   

                                                                                  }

                                                                                   

                                                                                   

                                                                                   

                                                                                  mysql_close($link);

                                                                                   

                                                                                   

                                                                                   

                                                                                   

                                                                                  • 38. Re: Mysql connection with 1and1.co.uk
                                                                                    osgood_ MVP

                                                                                    PBrackett12 wrote:

                                                                                     

                                                                                    Ok, I think I did what I was supposed to do - although I got a bit lost.  But the result was the following when I uploaded it:  Parse error: syntax error, unexpected '=' in /homepages/41/d259550773/htdocs/oakfieldstables/login.php on line 6

                                                                                     

                                                                                    For the sake of clarity I've provided the code:

                                                                                     

                                                                                    <!-- <?php require_once('Connections/Testserver.php'); ?> -->

                                                                                    <?php

                                                                                     

                                                                                    $hostname="dbXXXX.db.1and1.com";

                                                                                     

                                                                                    $database_conTestserver.php = "dbXXXX";

                                                                                     

                                                                                    $username="dboXXXX";

                                                                                     

                                                                                    $password="XXXX";

                                                                                     

                                                                                     

                                                                                     

                                                                                    $link = mysql_connect($hostname, $username, $password);

                                                                                     

                                                                                    if (!$link) {

                                                                                     

                                                                                    die('Connection failed: ' . mysql_error());

                                                                                     

                                                                                    }

                                                                                     

                                                                                    else{

                                                                                     

                                                                                    echo "Connection to MySQL server " .$hostname . " successful!

                                                                                     

                                                                                    " . PHP_EOL;

                                                                                     

                                                                                    }

                                                                                     

                                                                                     

                                                                                     

                                                                                    $db_selected = mysql_select_db("dbXXXX", $link);

                                                                                     

                                                                                    if (!$db_selected) {

                                                                                     

                                                                                    die ('Can\'t select database: ' . mysql_error());

                                                                                     

                                                                                    }

                                                                                     

                                                                                     

                                                                                     

                                                                                    mysql_close($link);

                                                                                     

                                                                                     

                                                                                     

                                                                                     

                                                                                     

                                                                                    The $database_con variable looks incorrect

                                                                                     

                                                                                    Open up the Testserver.php in the Connections folder and look for the $database_con line. I doubt it will have .php appended to it?

                                                                                     

                                                                                    It will be like the below, right?

                                                                                     

                                                                                    $database_conTestserver = "dbXXXX";

                                                                                     

                                                                                     

                                                                                    Amend the line in the block of php connection code and see what happens.

                                                                                    • 39. Re: Mysql connection with 1and1.co.uk
                                                                                      PBrackett12 Community Member

                                                                                      I don't seem to have a $database_con line - below is the entirety of my Testserver.php file:

                                                                                       

                                                                                      <?php

                                                                                      1. FileName="Connection_php_mysql.htm"

                                                                                      2. Type="MYSQL"

                                                                                      3. HTTP="true"

                                                                                      $hostname_Testserver = "Oakfield_db";

                                                                                      $database_Testserver = "dbXXXX.db.1and1.com";

                                                                                      $username_Testserver = "dboXXXX";

                                                                                      $password_Testserver = "XXXX";

                                                                                      $Testserver = mysql_pconnect($hostname_Testserver, $username_Testserver, $password_Testserver) or trigger_error(mysql_error(),E_USER_ERROR);

                                                                                       

                                                                                      1 2 3 Previous Next