Connecting to remote MySQL server.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eragon
    Contributor
    • Mar 2007
    • 431

    Connecting to remote MySQL server.

    i tried using Awardspace.com fot the MySQL servers, and i keep getting errors from the server. So i tried 110mb.com for their servers, and still, i get errors! i put the information that they sent me into my scripts, and it wont work for me... so sad... for my username would i put sqltestsite_sql db (sqltestsite is the name of my site, sqldb is my user) or would i just put sqldb? and for the host, would http://fdb1.awardspace .com/ work, or do i need to just put fdb1.awardspace .com, or is there a completely differend prefix i put?? PLease help!!!

    Hoping you help,

    Eragon
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I've edited the thread's title.

    Please use good, descriptive, thread titles when you post new threads.
    Refrain from using phrases like: 'Please help' or 'Need help' or just 'Help'.

    Please read our Posting Guidelines before posting.

    MODERATOR

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Could you show us the error's your getting, and perhaps some relevant code?

      It's extremely hard to debug code you can't see.

      Comment

      • eragon
        Contributor
        • Mar 2007
        • 431

        #4
        sorry about that, im just getting a little frustrated... i cant get a good content management system working... i spent 2 hours following a tutorial, and when i was done, all i got was errors from my sql server. i need another sql server...

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Originally posted by eragon
          i tried using Awardspace.com fot the MySQL servers, and i keep getting errors from the server.
          What errors are you getting? That ESP helmet I bought last year is still on backorder...

          Originally posted by eragon
          for my username would i put sqltestsite_sql db
          To connect to a MySQL server:
          [code=php]
          $handle = mysql_connect(' hostname', 'username', 'password');
          mysql_select_db ('database', $handle);
          [/code]

          Originally posted by eragon
          http://fdb1.awardspace .com/ work, or do i need to just put fdb1.awardspace .com, or is there a completely differend prefix i put
          You'd use fdb1.awardspace .com, since you're not using the http protocol.

          For more information:

          Comment

          • eragon
            Contributor
            • Mar 2007
            • 431

            #6
            Originally posted by Atli
            Could you show us the error's your getting, and perhaps some relevant code?

            It's extremely hard to debug code you can't see.
            certainly, here is my PHP code, one of the many:

            [PHP]<?php
            // set your infomation.
            $dbhost='http://fdb1.awardspace .com';
            $dbusername='sq ldb';
            $dbuserpass='** ****';
            $dbname='sqldb' ;

            // connect to the mysql database server.
            mysql_connect ($dbhost, $dbusername, $dbuserpass);
            //select the database
            mysql_select_db ($dbname) or die('Cannot select database');

            //create the table, customize it if you want
            $query = "CREATE TABLE peep_online(
            activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
            member ENUM('y','n') NOT NULL DEFAULT 'n',
            ip_address VARCHAR(255) NOT NULL,
            refurl VARCHAR(255) NOT NULL,
            user_agent VARCHAR(255) NOT NULL)";
            $result = mysql_query($qu ery);
            echo "Table Created!";
            ?>[/PHP]

            (stars subsituted for password)

            and here is the error i get when i run the code:

            Warning: mysql_connect() : Lost connection to MySQL server during query in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 9

            Warning: mysql_select_db (): Unknown MySQL Server Host 'db1.awardspace .com' (1) in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 11

            Warning: mysql_select_db (): A link to the server could not be established in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 11
            Cannot select database

            i cant see what i am doing wrong... or can i ?

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Originally posted by eragon
              Warning: mysql_select_db (): Unknown MySQL Server Host 'db1.awardspace .com' (1) in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 11
              Is your MySQL server on the same machine / at the same address as your web server? In which case, you can use 'localhost' as the host name.

              Comment

              • eragon
                Contributor
                • Mar 2007
                • 431

                #8
                im just looking for a really easy way to edit the files on my website with a simple HTML form, and for those said files to remain that way untill i submit other data from the form mentioned above. I also need a way to append to the files for like, say a news bulletin that need to have articles added to it. i have the forms made, and they look great, now i need a PHP script that will take the data submitted by said forms and relay it back to the page of which the forms are meant to edit. All other systems i used (over 15) dont want to work. from the information i gathered, the information sent by the forms is stored in a MySQL database, and then retreived when a user loads the page and posted where it is supposed to go on said page. i have not the knowledge of PHP to complete these tasks alone, therefore i am turning to the forums to help me. (and Google is useless) can you help me?

                If you want me to give more specific detail just ask.

                Sincerely,

                Eragon

                P.S. WOOT! Im not a newbie no more! Im a member =p

                Comment

                • eragon
                  Contributor
                  • Mar 2007
                  • 431

                  #9
                  ill try using localhost for the server name, and ill remove the http://

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    btw you should add a die() call after your mysql_connect() function, so your code wont show you extra error messages. Only the first of you three error messages is needed, as the last two are a caused by the first one and serve only to cause confusion.
                    Last edited by Atli; May 27 '07, 05:14 PM. Reason: Holy cow you guys write fast!

                    Comment

                    • eragon
                      Contributor
                      • Mar 2007
                      • 431

                      #11
                      what if i remove the " or die('Cannot select database') " part?

                      Comment

                      • eragon
                        Contributor
                        • Mar 2007
                        • 431

                        #12
                        that answers my question

                        Comment

                        • eragon
                          Contributor
                          • Mar 2007
                          • 431

                          #13
                          lol, i wirte fast, i keep getting a "wait 30 secs" message

                          Comment

                          • eragon
                            Contributor
                            • Mar 2007
                            • 431

                            #14
                            Originally posted by Atli
                            btw you should add a die() call after your mysql_connect() function, so your code wont show you extra error messages. Only the first of you three error messages is needed, as the last two are a caused by the first one and serve only to cause confusion.

                            How do i fix the first error??? ill add another die() thing, ill see if it works

                            Comment

                            • eragon
                              Contributor
                              • Mar 2007
                              • 431

                              #15
                              changed code, looks like this:

                              [PHP]<?php
                              // set your infomation.
                              $dbhost='localh ost';
                              $dbusername='12 21581815_sqldb' ;
                              $dbuserpass='** ****';
                              $dbname='122158 1815_sqldb';

                              // connect to the mysql database server.
                              $handle = mysql_connect(' dbhost', 'dbusername', 'dbpassword');
                              mysql_select_db ('dbname', $handle);

                              //create the table, customize it if you want
                              $query = "CREATE TABLE peep_online(
                              activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
                              member ENUM('y','n') NOT NULL DEFAULT 'n',
                              ip_address VARCHAR(255) NOT NULL,
                              refurl VARCHAR(255) NOT NULL,
                              user_agent VARCHAR(255) NOT NULL)";
                              $result = mysql_query($qu ery);
                              echo "Table Created!";
                              ?>[/PHP]

                              and i get this in return:


                              Warning: mysql_connect() : Lost connection to MySQL server during query in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 9

                              Warning: mysql_select_db (): Unknown MySQL Server Host 'db1.awardspace .com' (1) in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 11

                              Warning: mysql_select_db (): A link to the server could not be established in /home/www/1221581815.awar dspace.com/peep_onlinecrea te.php on line 11
                              Cannot select database


                              its like a plague!!! ill be back soon, im gonna take break, my computers trying to bite me...

                              Comment

                              Working...