Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

66 users online



Sessions...and crap.

Sessions...and crap.

Currently viewing this thread: 1 (0 members and 1 guests)


Aki

Aki

Neverside Newbie
Status: Offline!

Sessions...and crap.

Hi.

I am currently trying to select something kind of like this:

PHP:

<?php
SELECT points FROM users WHERE username
='$username'
?>

Except the username variable is registered in a session. How can I select points from users where username='$the_username_that_they_logged_into_sessions'? I am using sessions for the member system so I need to select stuff from the db.

Understand? Heh... Basically, how would the query look if I am trying to select something using a variable from sessions?

EDIT: To explain myself further, just as a little extra note, I need to turn the username used in the session into something I can use in a MySQL query. Hopefully you get now what I am trying to do.

Last edited by Aki, August 31st, 2005 01:50 AM (Edited 1 times)

Dachande663

Dachande663

Web Developer & Geek
Status: Offline!

If you have stored the username as a session variable then you should be able to just use:
SELECT points FROM users WHERE username=$_SESSION['username']

___________________

http://www.hybridlogic.co.uk/sig.jpg
http://www.hybridlogic.co.uk/winamp.jpg

Aki

Aki

Neverside Newbie
Status: Offline!

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site6/fst/var/www/html/akipets/welcomeback.php on line 34

Line 34 is:

PHP:

<?php
            $query 
"SELECT points FROM users WHERE username=$_SESSION['username']";
?>

gregor

gregor

Neverside Newbie
Status: Offline!

Try

PHP:

<?php

$query 
"SELECT points FROM users WHERE username = " $_SESSION['username'];

?>

___________________

sixminutes.ca

Rad

Rad

thinking of something witty to put here
Status: Offline!

You can also use the complex syntax (PHP's name for it):

PHP:

<?php

$query 
"SELECT points FROM users WHERE username = '{$_SESSION['username']}'";

?>

Aki

Aki

Neverside Newbie
Status: Offline!

Yay, no more ugly parse errors

PHP:

<?php

            $query 
"SELECT points FROM users WHERE username = '{$_SESSION['username']}'";
            
$result mysql_query($query) or die(mysql_error());
            
$row mysql_fetch_assoc($result);
            {
            echo 
''.$row['points'].'';
            }

?>

There is the coding. But it's not echoing or displaying the points row. How can I fix this. I need it to display the row 'points.'

By the way, it's not pulling it up now because the 'username' isn't my primary column. Is there a possible why I can make it select by 'username' column? I heard you could make a column a 'special column' or something? Or maybe I just have to change and register the user id in the session. I don't know.

EDIT: Okay I got it to select by userid! Just register the userid in the session variable whatever... *can't talk in programming language*

PROBLEM SOLVED. THANKS SO MUCH.

Last edited by Aki, August 31st, 2005 02:50 AM (Edited 2 times)

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0084 seconds.