SQL query help

Discussion in 'PHP' started by Dirty-Rockstar, Aug 15, 2007.

  1. #1
    agh, im about to pull my hair out. im so lost!!!


    I want to query a table called users, select house where the userID matches the session. and i cannot seem to figure it out


    
    
    $housequery1="SELECT house FROM users WHERE userID='{$sessionvar[userID]}'"
     or die(mysql_error());
    $housequery=mysql_query($housequery1) or die(mysql_error());
    
    PHP:
    I thnk the issue is the userID end of things. I tried to print $housequery1 and got this

    Then i had the bright idea of maybe i need to get the id from the address bar or something....soooo i tried this above the query:

    
    
    $_GET['$sessionvar[userID]'];
    $id = $_GET['$sessionvar[userID]'];
    
    
    PHP:
    What my attempt was to grab the userID and then attach it to a variable to replace '{$sessionvar[userID]}' in the query.
    That didnt work. even when i tried to print nothing came up
    AGHHHHHH!!!111oneone

    I think you need this information too:

    
    
    $_SESSION['loggedin']=1;
    $sessionvar=mysql_fetch_array($userquery);
    $_SESSION['userID']=$sessionvar[userID];
    
    
    PHP:

    how can i get this to work!

    PS field values in house are TINYINT from 1-9

    ~~thanks in advance
     
    Dirty-Rockstar, Aug 15, 2007 IP
  2. mrburns

    mrburns Peon

    Messages:
    9
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is the user id already set in a session variable? If so I would try

    $housequery1="SELECT house FROM users WHERE userID='{$_SESSION['userID']}'"
     
    mrburns, Aug 15, 2007 IP
    Dirty-Rockstar likes this.
  3. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    BAM!!

    1+ tyvm
     
    Dirty-Rockstar, Aug 15, 2007 IP