By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Having a User identification problem

P: n/a
I have a phpBB board with some of my users in a particular
usergroup...using the following query:

$usrresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
phpbb_sessions ON phpbb_users.user_id = phpbb_sessions.session_user_id
WHERE phpbb_users.user_id =phpbb_sessions.session_user_id AND
phpbb_sessions.session_time >= ".( time() - 300 ). " AND
phpbb_users.user_id >1");

I am able to dispaly who is currenlty logged in by looping through the
following:

while( $showusr = mysql_fetch_array($usrresult)){
echo( $showusr["username"]);
}

Ok....now...using this query:

$grpresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
phpbb_user_group ON phpbb_users.user_id = phpbb_user_group.user_id
WHERE group_id =(my group's id#)");

I am able to loop through the list of all the users I have in a
particular group by the group id, by doing the following:

while($row = mysql_fetch_array($newresult)) {
echo( "<tr><td>" . $row["user_id"] . "</td><td>" . $row["username"] .
"</td></tr>");
}

what I CANT seem to do is figure out how to tell "YOU" that "YOU" are
"YOU" and display that information on a page...I have tried using
this...

$theuser = "SELECT u.username, .user_id, .user_allow_viewonline,
..user_level, s.session_logged_in, s.session_ip FROM ".USERS_TABLE." u,
".SESSIONS_TABLE." s WHERE u.user_id = s.session_user_id AND
s.session_time >= ".( time() - 300 ) . " $user_forum_sql ORDER BY
u.username ASC, s.session_ip ASC";

$youare = mysql_fetch_array($theuser);

and calling echo( $youare["username"]);

to display the username data, which on the surface, only APPEARS to
work...in fact, it returns the username of that last logged in
session.

I need a way to be able to identify "YOU" as "YOU" to display that
information to you, instead of the username of whoever logged in last.

any clues what Im doing wrong?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Anybody?
Anything?

"Geo H" <gh******@netzero.net> wrote in message
news:e8**************************@posting.google.c om...
: I have a phpBB board with some of my users in a particular
: usergroup...using the following query:
:
: $usrresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
: phpbb_sessions ON phpbb_users.user_id = phpbb_sessions.session_user_id
: WHERE phpbb_users.user_id =phpbb_sessions.session_user_id AND
: phpbb_sessions.session_time >= ".( time() - 300 ). " AND
: phpbb_users.user_id >1");
:
: I am able to dispaly who is currenlty logged in by looping through the
: following:
:
: while( $showusr = mysql_fetch_array($usrresult)){
: echo( $showusr["username"]);
: }
:
: Ok....now...using this query:
:
: $grpresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
: phpbb_user_group ON phpbb_users.user_id = phpbb_user_group.user_id
: WHERE group_id =(my group's id#)");
:
: I am able to loop through the list of all the users I have in a
: particular group by the group id, by doing the following:
:
: while($row = mysql_fetch_array($newresult)) {
: echo( "<tr><td>" . $row["user_id"] . "</td><td>" . $row["username"] .
: "</td></tr>");
: }
:
: what I CANT seem to do is figure out how to tell "YOU" that "YOU" are
: "YOU" and display that information on a page...I have tried using
: this...
:
: $theuser = "SELECT u.username, .user_id, .user_allow_viewonline,
: .user_level, s.session_logged_in, s.session_ip FROM ".USERS_TABLE." u,
: ".SESSIONS_TABLE." s WHERE u.user_id = s.session_user_id AND
: s.session_time >= ".( time() - 300 ) . " $user_forum_sql ORDER BY
: u.username ASC, s.session_ip ASC";
:
: $youare = mysql_fetch_array($theuser);
:
: and calling echo( $youare["username"]);
:
: to display the username data, which on the surface, only APPEARS to
: work...in fact, it returns the username of that last logged in
: session.
:
: I need a way to be able to identify "YOU" as "YOU" to display that
: information to you, instead of the username of whoever logged in last.
:
: any clues what Im doing wrong?
Jul 17 '05 #2

P: n/a
George Hernandez wrote:
Anybody?
Anything?

"Geo H" <gh******@netzero.net> wrote in message
news:e8**************************@posting.google.c om...
: I have a phpBB board with some of my users in a particular
: usergroup...using the following query:
:
: $usrresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
: phpbb_sessions ON phpbb_users.user_id = phpbb_sessions.session_user_id
: WHERE phpbb_users.user_id =phpbb_sessions.session_user_id AND
: phpbb_sessions.session_time >= ".( time() - 300 ). " AND
: phpbb_users.user_id >1");
:
: I am able to dispaly who is currenlty logged in by looping through the
: following:
:
: while( $showusr = mysql_fetch_array($usrresult)){
: echo( $showusr["username"]);
: }
:
: Ok....now...using this query:
:
: $grpresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
: phpbb_user_group ON phpbb_users.user_id = phpbb_user_group.user_id
: WHERE group_id =(my group's id#)");
:
: I am able to loop through the list of all the users I have in a
: particular group by the group id, by doing the following:
:
: while($row = mysql_fetch_array($newresult)) {
: echo( "<tr><td>" . $row["user_id"] . "</td><td>" . $row["username"] .
: "</td></tr>");
: }
:
: what I CANT seem to do is figure out how to tell "YOU" that "YOU" are
: "YOU" and display that information on a page...I have tried using
: this...
:
: $theuser = "SELECT u.username, .user_id, .user_allow_viewonline,
: .user_level, s.session_logged_in, s.session_ip FROM ".USERS_TABLE." u,
: ".SESSIONS_TABLE." s WHERE u.user_id = s.session_user_id AND
: s.session_time >= ".( time() - 300 ) . " $user_forum_sql ORDER BY
: u.username ASC, s.session_ip ASC";
:
: $youare = mysql_fetch_array($theuser);
:
: and calling echo( $youare["username"]);
:
: to display the username data, which on the surface, only APPEARS to
: work...in fact, it returns the username of that last logged in
: session.
:
: I need a way to be able to identify "YOU" as "YOU" to display that
: information to you, instead of the username of whoever logged in last.
:
: any clues what Im doing wrong?


then the relavent question to ask is: when is the user record written to the
database? before or after you get to this section of code?

since you should be passing the session id on the page/post/get and it is
unique, then the query should relfect that...
add:
$usrresult = mysql_query( "SELECT * FROM phpbb_users INNER JOIN
phpbb_sessions ON phpbb_users.user_id = phpbb_sessions.session_user_id
WHERE phpbb_users.user_id =phpbb_sessions.session_user_id AND

phpbb_sessions.session_user_id = $_SESSION... you get the picture

phpbb_sessions.session_time >= ".( time() - 300 ). " AND
phpbb_users.user_id >1");

I would modify the query to only get the max session time where the sessionid =
$sessionid. When dealing with sessions in this manner, you should be looking for
a "singleton-select" - a query that only has one result row.

--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.