I looked through this entire thread and absolutely none of this is right. Pheonix stores the array/dictionary/list/(what ever it is) of live connections in the database as positive integer. That is the most reliable online count. For the people that are doing the following:
Code:
print mysql_num_rows(mysql_query("SELECT users_online FROM server_status"));
You are completely wrong. First of all this will always be "1"?
For the people doing the following:
Code:
print mysql_result(mysql_query("SELECT COUNT(*) FROM users WHERE online = '1'"), 0);
or
Code:
print mysql_num_rows(mysql_query("SELECT * FROM users WHERE online = '1'"));
... you are again wrong. This will fetch all the users with an online status of 1. If your vps randomly restarts or the emulator randomly quits it does not restore everyone to online = '0'. Some will still be left as online = '1'.
With all that being said, I imagine a lot of you (for some odd reason) are all wondering what is the correct way to gather the online count? The most proper way to find the online count in Phoenix is by doing the following:
Code:
$hostname = 'localhost';
$port = 8889;
$username = 'root';
$password = 'root';
$database = 'pheonix_database';
mysql_connect("{$hostname:$port}", $username, $passord);
mysql_select_db($database);
print mysql_result(mysql_query("SELECT ss.users_online FROM server_status ss LIMIT 0,1;"), 0);
Hopefully you will all learn from this. For the record, I cannot believe we are actually discussing how to get the online count... it truly explains so much. Aim high?