MyBB Community Forums

Full Version: [F] Who's Online - Internal SQL Error [C-Michael83]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Clicking on Who's Online [Complete List] generates the following error:

MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1 - no such column: count_sid
Query:
SELECT COUNT(count_sid) FROM mybb_sessions WHERE (SELECT DISTINCT sid as count_sid FROM mybb_sessions WHERE time > 1229895917)

This is on clean, brand new install of MyBB 1.4.4 on PHP 5.1.6 using SQLite 2.8.17. No plugins.
The same problem was happening on 1.4.3.
Try this. In online.php find:

// Exactly how many users are currently online?
	switch($db->type)
	{
		case "sqlite3":
		case "sqlite2":	
			$query = $db->simple_select("sessions", "COUNT(count_sid)", "(SELECT DISTINCT sid as count_sid FROM ".TABLE_PREFIX."sessions WHERE time > {$timesearch})");
			break;
		case "pgsql":
		default:
			$query = $db->simple_select("sessions", "COUNT(DISTINCT sid) as online", "time > {$timesearch}");
			break;
	}
	$online_count = $db->fetch_field($query, "online");

replace with

// Exactly how many users are currently online?
	switch($db->type)
	{
		case "sqlite3":
			$query = $db->simple_select("sessions", "COUNT(count_sid)", "(SELECT DISTINCT sid as count_sid FROM ".TABLE_PREFIX."sessions WHERE time > {$timesearch})");
			$online_count = $db->fetch_field($query, "online");
			break;
		case "sqlite2":
			$sessions = array();
			$query = $db->simple_select("sessions", "sid", "time > {$timesearch}");
			while($sid = $db->fetch_field($query, "sid"))
			{
				$sessions[$sid] = 1;
			}
			$online_count = count($sessions);
			unset($sessions);
			break;
		case "pgsql":
		default:
			$query = $db->simple_select("sessions", "COUNT(DISTINCT sid) as online", "time > {$timesearch}");
			$online_count = $db->fetch_field($query, "online");
			break;
	}
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group
Applied the fix, it is working fine.

Thank you,
Bill