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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    i want a an example to insert user id via either session?

    <?php
    $user = /* insert user id via either session */
    $query = " SELECT user_name, user_point
    FROM users
    INNER JOIN roles ON role_id = fk_roles_id
    WHERE user_id =.$user.";
    $result = mysqli_query($database_link, $query) or if_sql_error_then_die(mysqli_error($database_link), $query, __LINE__, __FILE__);
    if (mysqli_num_rows($result) > 0)
    {
    while ($row = mysqli_fetch_assoc($result))
    {
    echo '
    <tr>
    <i class="icon-pencil"></i>
    </td>
    <td style="width:30px;">

    </td>
    <td>'.$row['user_name']. '</td>
    <td> &nbsp;&nbsp;&nbsp;&nbsp;<strong>'.$row['user_point'].' Point</strong></td>
    </tr>';
    }
    }

    ?>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    I don't see *ANY* SESSION used anywhere in that code. What are you talking about?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    PHP Code:
    session_start();
    if (isset(
    $_SESSION['userid']))
    {
        
    $user $_SESSION['userid'];
        
    // all the rest of the code here

    Also, this won't work: WHERE user_id =.$user.";. The '.'s here are for concatenation; that's only useful if you plan on breaking out of the string. Remove the periods from there.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Okay, FouLu...but how does this have anything to do with "EITHER session"???

    I still see only ONE session value there.

    Further, if there is no session value available, the query will try to get a blank or null userid, which makes less sense.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    It doesn't, I'm still trying to work out in my mind where the via either fits in here too O.o
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing 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
    •