38 users online (0 members and 38 guests)  


  Results 1 to 4 of 4
  1. #1
    medvegonok's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2006
    Posts
    5

    2 connections problem

    I create 2 connectionsand then try to select the current active database:

    $aaa_link = mysql_connect("host1","user1","pass1") or die(mysql_error());
    $bbb_link = mysql_connect("host2","user2","pass2")or die(mysql_error());

    mysql_select_db("dbname1", $aaa_link) or die(mysql_error());

    However, mysql_select_db fails with error:

    Access denied for user: "user2" to database "dbname1"

    What is wrong here?

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: 2 connections problem

    Try connecting to one database at a time first, making sure that works. Then try both of them again. Also, I have to ask: Are you absolutely sure that you've used the correct username/password combination for the respective databases?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    medvegonok's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2006
    Posts
    5

    Re: 2 connections problem

    Sorry, mistake - host1 = host2, but users, passwords and dbnames there are different. By the way the next code worked perfectly:
    $aaa_link = mysql_connect("host1","user1","pass1") or die(mysql_error());
    mysql_select_db("dbname1", $aaa_link) or die(mysql_error());
    That is the bbb_link's line that caused this problem for some reason. It appears as if after the second mysql_connect the mysql tries to work on the $bbb_link database and ignores the existence of $aaa_link.

  4. #4
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: 2 connections problem

    Have you tried this by itself?

    Code:
    $bbb_link = mysql_connect("host2","user2","pass2")or die(mysql_error()); 
    
    mysql_select_db("dbname2", $bbb_link) or die(mysql_error());
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more



Tags for this Thread