$DB_site->query("UPDATE user SET lastchatactivity = '$lastvisit' WHERE userid='$bbuserinfo[userid]'");
for the second query. The query is saying that there isn't a value for $lastvisit so that's maybe why youre getting the error. Make sure $lastvisit has a value too.