Retrieve userid of logged in user for use to insert into another table - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: Retrieve userid of logged in user for use to insert into another table

  1. #16
    Junior Member
    Join Date
    Apr 2013
    Posts
    13
    If I added the following code:
    $sql="SELECT userid FROM users WHERE username = $_SESSION['username']";
    $result = mysql_query($sql);
    $_SESSION = $result;

    I just want to snag the userid as the user is loggin in and store it for fast retrieval and usage. I may not be understanding what you're saying, so please help me understand what you mean. Once the user LOGS IN, I want to store their userid with everything they do. Think of it like your e-mail on yahoo...everything you do in yahoo is linked to your name, you can't see other yahoo users' mail...just your own.

  2. #17
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,432
    That code won't be very useful, because you're trying to store the value returned by mysql_query() into a session. That function does not return a scalar value - it returns a resource. (And then there is, of course, the matter with the invalid syntax in the SQL query.)

  3. #18
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,906
    Quote Originally Posted by aarontbarksdale
    I just want to snag the userid as the user is loggin in and store it for fast retrieval and usage. I may not be understanding what you're saying, so please help me understand what you mean. Once the user LOGS IN, I want to store their userid with everything they do
    That's pretty much what I said, but with more detail about what needs to be done.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Tags for this Thread

Posting Permissions

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