SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Connecting to MySQL with PHP

    Hi,

    I have already used Kevin Yank's book to set up 2 small database driven sites, but now I've come across a problem with a new client who is using netnation.com to host her site.

    They setup the access to the MySQL database and gave us the same database name as the username (firefit).

    To start the MySQL database from the command line, I must be logged into the account with ssh and do the following:

    export MYSQL_HOST=db.netnation.com
    export MYSQL_TCP_PORT=4000
    export MYSQL_PASSWD='mypass'

    then I can start the database with:
    /usr/local/mysql/bin/mysql -u firefit -p firefit

    OR, if I don't export the variables, I can start it directly with:
    /usr/local/mysql/bin/mysql -h db.netnation.com -P 4000 -u firefit -p firefit

    My problem now is that I can't connect to the MySQL server directly - I can only connect directly to the database.

    So when I have the code:

    $dbcnx =
    @mysql_connect("db.netnation.com", "firefit", "password");
    if (!$dbcnx)
    { echo("no connection made");
    exit;
    }
    else
    { echo("we made it!");
    exit;
    }

    I always get the "no connection made".

    I have also tried with "localhost" and with "127.0.0.1" and still nothing.

    Is there a way to make a direct connection to the database, not just the MySQL server? Is there a way around this?

    I have contacted netnation, but they have not been very helpful so far.

    Thanks!

    Christine.

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you have your password correct? In the above example where you CAN connect the password is firefit (same as username).

    Are you using the same details to connect?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that, I didn't mean to type in the extra firefit at the end.

    When I do the command line login, whether I type the "-p firefit" or just "-p" at the end, I still get prompted for my password and if I put the correct one in, then I get access.

    I tried, for fun, putting firefit in, and it doesn't work.

    I'm thinking that maybe it has something to do with the -P 4000 that I need to put if I don't export the variables? Is there a way to specify this through php?

    Thanks!

    Christine.

  4. #4
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK you could try this... (don't know if it is even valid):

    PHP Code:
    @mysql_connect("db.netnation.com:4000""firefit""password"); 
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  5. #5
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works beautifully!

    Thanks for the help!

    Christine .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •