Connecting to multiple MySQL DB in PHP

Discussion in 'Software' started by theprocrastinater, Jun 30, 2004.

  1. theprocrastinater

    theprocrastinater Private E-2

    Hey, I'm working on a new project which will involve constant switching between two DB's. The only way I can do that at the moment is to keep reopening each one as I need it, so I've tried to use the following script to keep both open all the time, but it isn't working.

    PHP:
    $dbhypo mysql_connect('127.0.0.1''root');
    mysql_select_db('hypostasis'$dbhypo);
    $dbdraw mysql_connect('127.0.0.1''root'); 
    mysql_select_db('draw'$dbdraw);
    $result mysql_query("SELECT * FROM gigs ORDER BY id DESC",$dbhypo);
    while (
    $row mysql_fetch_object($result)) {
    echo 
    $row->venue;
    }
    $result mysql_query("SELECT * FROM gigs ORDER BY id DESC",$dbdraw);
    while (
    $row mysql_fetch_object($result)) {
    echo 
    $row->venue;
    }
    Both $dbhypo and $dbdraw seem be accessing the draw database. Please help!
     
  2. theprocrastinater

    theprocrastinater Private E-2

    Sorry if I wasted anyones time, but I sorted the problem out myself, for some reason it just started working when I used a different user to connect to each time.
     
  3. ICeMaN

    ICeMaN Master Sergeant

    having the same user connect to each probably caused a loop error? I've just started messing with this stuff myself :\
     
  4. goldfish

    goldfish Lt. Sushi.DC

    I think it was because you cant use the same user twice for opening different DBs at the same time. Somthing like that. Very confuddling.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds