2Code
Posts: 24
|
Posted: 04/12/2014, 9:50 PM |
|
Ok I have a table in row in table users and I am trying to update the table to 1 when user logs in I modified my common php to the following
//CCLoginUser @0-CA04CFE5
function CCLoginUser($login, $password)
{
CCLogoutUser();
$db = new clsDBlocalhost();
$SQL = "SELECT uid, user_level, user_pwd FROM users WHERE username=" . $db->ToSQL($login, ccsText) . " AND user_pwd=" . $db->ToSQL(md5($password), ccsText);
$db->query("UPDATE users SET user_online = '1', LastVisit = Now() WHERE username ='".$login."'");
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
CCSetSession("uid", $db->f("uid"));
CCSetSession("username", $login);
CCSetSession("user_level", $db->f("user_level"));
CCSetSession("UserAddr", $_SERVER["REMOTE_ADDR"]);
}
return $Result;
}
//End CCLoginUser
How ever it does not update the user_online field to 1 I have been over it a million times but know I am missing something
then I have my cclogout in common to
//CCLogoutUser @0-F63B51EE
$db = new clsDBlocalhost();
$SQL= "UPDATE users SET user_online = '0', logout = Now() WHERE username ='".CCGetSession("username")."'";
$db->query($SQL);
function CCLogoutUser()
{
CCSetSession("uid", "");
CCSetSession("username", "");
CCSetSession("user_level", "");
CCSetSession("UserAddr", "");
}
//End CCLogoutUser
it is suppose to set the user_online to 0 but it is not working either the row remains 0 all the time... am I missing something???
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 04/13/2014, 5:09 PM |
|
I haven't gone through all your code but looks like there's a few too many of these "
In this:
WHERE username ='".$login."'");
I would do this as such:
WHERE username = '$login' ");
_________________
Central Coast, NSW, Australia.
|
|
|
2Code
Posts: 24
|
Posted: 04/13/2014, 7:24 PM |
|
Hey Michael I appreciate your response I have tried it every way even as you suggested and still the same result the database does not get updated.
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 04/13/2014, 11:55 PM |
|
Try something like this ....
$SQL = "UPDATE USERS set online ='1' " . "," . "time = NOW() " . "WHERE username = '$login' ";
$db->query($SQL);
_________________
Central Coast, NSW, Australia.
|
|
|
2Code
Posts: 24
|
Posted: 04/15/2014, 1:27 AM |
|
Nope its still not setting the value to 1 in the user_online field I have ccs5.1
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 04/15/2014, 3:22 AM |
|
You are attempting to update with username as a session variable before the value for the session variable is even set.
Read the PHP files here and come up to speed on query logic ...
php.net
_________________
Central Coast, NSW, Australia.
|
|
|
|