MyBB Community Forums
[F] Who's Online - Internal SQL Error [C-Michael83] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] Who's Online - Internal SQL Error [C-Michael83] (/thread-42332.html)



[F] Who's Online - Internal SQL Error [C-Michael83] - billyj - 12-21-2008

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.


RE: Who's Online - Internal SQL Error - Ryan Gordon - 12-21-2008

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;
	}



[F] Who's Online - Internal SQL Error - Ryan Gordon - 12-22-2008

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


RE: [F] Who's Online - Internal SQL Error - billyj - 12-24-2008

Applied the fix, it is working fine.

Thank you,
Bill