How to connect to mysql online database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chuckzter
    New Member
    • Oct 2007
    • 56

    How to connect to mysql online database

    Greetings,


    I'm having this error , Can't connect to MySQL server on '_______' (10061)

    I have a lot of questions running in my head right now,

    first is, the '___' on top, should it be an ip of the server?
    also, should i have my php and html file uploaded?

    What i'm actually trying to do is do an insert command to my mysql database, I don't have my html file and php file uploaded, i'm just running them on my desktop or local drive.

    How can i make this work?

    If it's any help, the address bar is (http://localhost/gwg/insert.php) which is where the php file and html file is located.

    Do i need to have my locally installed xampp running?

    If you need any clarifications please reply to this post.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Okay, wow, where do I begin.

    Yes. Xamp must be running.

    "localhost" is an acronym for "this computer". So if we type that into our browser, it would try to find the folder gwg with file 'insert.php' on our computer, which of course does not exist (even if we did have xamp running)

    I don't know why your getting those lines for the mysql host, but if mysql is located on your computer, you should put something like 'localhost', '127.0.0.1' or the IP address of your machine.

    Since all of this is local, the files don't need to be 'uploaded' anywhere, they just needed to be in the folder that Apache is xamp is serving. (I've never used, never will use xamp, so don't ask me)

    If you have PHP running and you're having trouble with the code, post the code here so we can help you fix it.




    Dan

    Comment

    • chuckzter
      New Member
      • Oct 2007
      • 56

      #3
      Here you go.

      Code:
      <?php
      $con = mysql_connect("82.197.130.38","319770_gwonder","*****");
      if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }
      
      mysql_select_db("319770_gwonder", $con);
      
      $sql="INSERT INTO reg_Userdb (user_Fname, user_Lname, user_Age, user_Etc)
      VALUES
      ('$_POST[fname]','$_POST[lname]','$_POST[age]','$_POST[ea]')";
      
      if (!mysql_query($sql,$con))
        {
        die('Error: ' . mysql_error());
        }
      echo "1 record added";
      
      mysql_close($con)
      ?>
      I'm using a free mysql hosting service, the site is... well... i'll just give you a pm if you need the site's address. I'm pretty sure i have the right password and username. I can't find any forum or community for the site where i can ask for some guidance.

      @dlite922: Thanks for the response. Hope we can solve this together with your help.
      Last edited by Markus; Sep 11 '09, 12:53 PM. Reason: Changed [quote] to [code].

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        does your mysql server allow remote access?

        Comment

        • chuckzter
          New Member
          • Oct 2007
          • 56

          #5
          I'm using host-ed.net.

          I'm not really sure checking on the "overview" for the free sign up right now. Also, i consulted someone from my school to try another free mysql hosting site just in case the one that's causing the problem is the host itself. I'll try to give you an update a little bit later.

          Note:

          Don't consider the site i listed above to be an advertisement, just wanted to know if somebody else is using that host.

          @Moderators:

          You can delete it if you want.

          Comment

          • chuckzter
            New Member
            • Oct 2007
            • 56

            #6
            Got it. I just had to upload my files to the server itself where my mysql is sitting. Thanks for all those who replied.

            Just to give a heads up, i might posting other questions in the near future. :p

            I just love bytes.

            Comment

            Working...