It uses two different SQL calls, one to create a new "session" record in a custom table, and another that increments a custom user record field and records the "last visit" time in the user record.
The queries are written correctly, I think, but I am having 2 problems.... 9as you can tell, I am somewhat new to PHP coding...)
The $user_id field is not available for some reason, and I can't figure out the proper time value to use in the UPDATE or INSERT queries...
The question is, what includes need to be added to make those values available, and what syntax am I missing to have them work properely ? I'm including the top parts of the code. The //'d lines are the ones I need to figure out.
Any suggestions would be greatly appreciated.
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// End session management
//
// UPDATE USER TABLE WITH CHAT VISITS AND CURRENT TIME
// $sql = "UPDATE " . USERS_TABLE . "
// SET user_chat_visits = user_chat_visits + 1, SET user_chat_last = UNIX_TIMESTAMP()
// WHERE user_id = '$user_id'";
// if (!$db->sql_query($sql))
// {
// message_die(CRITICAL_ERROR, "Could not update user chat data", "", __LINE__, __FILE__, $sql);
// }
// Create a chat session
// $sql = "INSERT INTO " . CHAT_SESSIONS_TABLE . " (user_id, sess_time)
// VALUES ('$user_id', int($currenttime))";
// if (!$db->sql_query($sql))
// {
// message_die(CRITICAL_ERROR, "Could not update chat session data", "", __LINE__, __FILE__, $sql);
// }