Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry using session variables in mysql queries

    My php code consists of getting a person's session_id() and placing that in a session variable for use in other pages.
    The thing is, though, that when i place a session variable in a mysql query, i get the following error:

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/e/r/i/ericjacobson01/html/index.php on line 11

    This is the part that php complains about:
    PHP Code:

    $_SESSION
    ['buyer_id'] = session_id();

    $istableset mysql_query("SELECT * FROM ' .$_SESSION['buyer_id'] '"); 

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    PHP Code:
    $_SESSION['buyer_id'] = session_id();

    $istableset mysql_query("SELECT * FROM ' .$_SESSION['buyer_id'] . '"); 
    missing "." (concatenation operator)

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    wrong
    $istableset = mysql_query("SELECT * FROM {$_SESSION['buyer_id']}");

  • #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    oops. you're right, of course.

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    lol i try, i didnt mean to sound rude by saying you were wrong its just i got other things to do and really did Post a quick reply

  • #6
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    I didn't take it as rude, you were right, I was out in left field - guess I should have actually read the line before I tried to debug it.


  •  

    Posting Permissions

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