$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");
$cookievalue = mysql_query("SELECT value
FROM setting
WHERE varname = 'cookietimeout'");
$cookietimeout = mysql_result($cookievalue, 0, 0);
$datecut = time()-$cookietimeout;
$invisibleregmember = "0";
$regmembers = mysql_query("SELECT DISTINCT username,invisible
FROM user,session
WHERE session.userid=user.userid AND session.lastactivity>$datecut AND invisible='0'
ORDER BY username ASC");