mysql counting rows in accounts table
#5

Code:
cache_get_field_content_int(0, registered, mysql);
pawn Code:
native cache_get_field_content_int(row, const field_name[], connectionHandle = 1);
It expects a column name to search for but `registered` is empty. The correct way would be:
pawn Code:
new Cache:aresult = mysql_query(mysql, "SELECT COUNT(*) AS total_accounts FROM `accounts`"),
    registered = cache_get_field_content_int(0, "total_accounts", mysql);
or
pawn Code:
new Cache:aresult = mysql_query(mysql, "SELECT COUNT(*) FROM `accounts`"),
    registered = cache_get_row_int(0, 0, mysql);
But you do not need a SELECT query at all. When you execute an INSERT query with auto increment, you retrieve the number generated (account ID) with `cache_insert_id`. This is how many players have registered (including deleted accounts).
Reply


Messages In This Thread
mysql counting rows in accounts table - by Filbert - 20.05.2020, 20:21
Re: mysql counting rows in accounts table - by jasperschellekens - 20.05.2020, 21:09
Re: mysql counting rows in accounts table - by Filbert - 21.05.2020, 04:44
Re: mysql counting rows in accounts table - by SharpenBlade - 21.05.2020, 05:43
Re: mysql counting rows in accounts table - by Calisthenics - 21.05.2020, 07:11
Re: mysql counting rows in accounts table - by SiaReyes - 21.05.2020, 07:12
Re: mysql counting rows in accounts table - by Filbert - 21.05.2020, 09:57

Forum Jump:


Users browsing this thread: 1 Guest(s)