mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Caps`, `PosX`, `PosY`, `PosZ`, `PosA`, `Health, `Armour`, `Skin`, `Thirst`, `Hunger`, `Banned`, `Bans`, `Kicks`, `Warns`, `Muted`, `Quests`, `TimeH`, `TimeM`, `Infection`, `Storage`, `Item1`, `Item2`, `Item3`, `Item4`, `Item5`, `Item6`, `Item7`, `Item8`, `Item9`, `Item10`)) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f, 100, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Caps`, `PosX`, `PosY`, `PosZ`, `PosA`, `Health, `Armour`, `Skin`, `Thirst`, `Hunger`, `Banned`, `Bans`, `Kicks`, `Warns`, `Muted`, `Quests`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f, 100, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`TimeH`, `TimeM`, `Infection`, `Storage`, `Item1`, `Item2`, `Item3`, `Item4`, `Item5`, `Item6`, `Item7`, `Item8`, `Item9`, `Item10`) VALUES (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)");
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
mysql_tquery(mysql, query1, "", "i", playerid);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
new query[256], temp[128], player_name[MAX_PLAYER_NAME];
GetPlayerName(playerid, player_name, MAX_PLAYER_NAME);
format(temp, sizeof(temp), "SELECT `%s`,`%s`,`%s`,`%s`,`%s`");
strcat(query, temp);
format(temp, sizeof(temp), ",`%s`,`%s`,`%s`,`%s`,`%s` FROM `%s`");
strcat(query, temp);
format(temp, sizeof(temp), " WHERE `%s` = '%q'", player_name);
strcat(query, temp);
You can also assign default values to some fields. It would shorten the query considerably.
|
[19:00:56] [DEBUG] mysql_format - connection: 1, len: 2024, format: "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Caps`, `PosX`, `PosY`, `PosZ`, `PosA`, `Health, `Armour`, `Sk..." [19:00:56] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`", callback: "(null)", format: "i" [19:00:56] [DEBUG] mysql_format - connection: 1, len: 2024, format: "INSERT INTO `accounts` (`TimeH`, `TimeM`, `Infection`, `Storage`, `Item1`, `Item2`, `Item3`, `Item4`, `Item5`, `Item6`, `Item7`,..." [19:00:56] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `accounts` (`TimeH`, `TimeM`, `Infection`, `Storage`", callback: "OnAccountRegister", format: "i" [19:00:56] [DEBUG] CMySQLQuery::Execute[] - starting query execution [19:00:56] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Armour`, `Skin`, `Thirst`, `Hunger`, `Banned`, `Bans`, `Kicks`, `Warns`, `Muted`' at line 1 [19:00:56] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError |