How to damn do this lol
#1

So i made a table in MySQL which will log server stats like total accounts and shit. I tested with the "TotalAccounts" row first:

pawn Код:
new stats[200];
    format(stats, sizeof(stats), "UPDATE `ServerStats` SET `TotalAccounts` ++");
 mysql_query(stats);
This is the code when someone registers, but in mysql_log.txt i get a SQL syntax error, lol.

My question is: How to increase the "TotalAccounts" row by 1?

The "TotalAccounts" is made in "integrer".
Reply
#2

Completely unnecessary since you have COUNT(*).
PHP код:
SELECT COUNT(*) AS TotalAccounts FROM playerdata 
Will output something like

TotalAccounts
42
For further reference, to increment a field:
PHP код:
UPDATE table SET field field 1 WHERE condition true 
Reply
#3

So in this way:

pawn Код:
new stats[200];
UPDATE ServerStats SET TotalAccounts= TotalAccounts + 1 WHERE condition = true;
mysql_query(stats);
Right?
Reply
#4

format(stats, sizeof(stats), "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1 WHERE condition = true");
Reply
#5

Ah ye forgot the format. K thx
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)