SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Gman's Avatar
    Join Date
    Jan 2002
    Location
    Sarasota, FL
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Would this query work (select_db)

    I know the join works, because I can echo $dbrow->ClientDB, However, the script still uses the initial database made at the begining of the script and does not use the $dbrow->ClientDB

    Am I doing something wrong?

    Code:
    //================ 
    // Connect to Database | From dbcon.php include file 
    //================ 
    DBcon($DB); 
    
    //================ 
    // Select our data from our DB 
    //================ 
    $db = mysql_query("SELECT myinfo.ClientDB FROM myinfo INNER JOIN clients ON myinfo.CompanyID = clients.CompanyID WHERE clients.username = '$_SESSION[username]'") or die(mysql_error()); 
    
    $dbrow = mysql_fetch_object($db); 
    
    //=============== 
    // Select Clients DB 
    //=============== 
    mysql_select_db($dbrow->ClientDB); 
    
    //Rest of code w/ queries which *should use $dbrow->ClientDB
    
    

  2. #2
    SitePoint Zealot Gman's Avatar
    Join Date
    Jan 2002
    Location
    Sarasota, FL
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ive updated the query to this, and it does indeed echo the ClientDB


    Code:
      
     
    //================ 
    // Select our data from our DB 
    //================ 
    $db = mysql_query("SELECT ClientDB FROM myinfo, clients WHERE myinfo.CompanyID = clients.CompanyID= '$_SESSION[username]'") or die(mysql_error()); 
    $dbrow = mysql_fetch_object($db); 
    //=============== 
    // Select Clients DB 
    //=============== 
    mysql_select_db($dbrow->ClientDB);
    //echo $dbrow->ClientDB;
    But after this login page, it goes to a white page with the error:
    "No Database Selected"

  3. #3
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are trying to select info from tables without first specifying which database you are connecting to.


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
  •