13.07.2016, 16:45
Hello,
I was working on my gamemode and I found a problem with saving queries into the database, actually I'm using MySQL R6 (Don't tell me to upgrade) - so, I found that accounts aren't being saved or added into the database.
Save/Update Query Codes:
Errors while attempt to update in queries:
Insert/Adding Codes (DIALOG):
Errors while attempt to insert a new data in the database:
I was working on my gamemode and I found a problem with saving queries into the database, actually I'm using MySQL R6 (Don't tell me to upgrade) - so, I found that accounts aren't being saved or added into the database.
Save/Update Query Codes:
pawn Код:
stock SavePlayer(playerid)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerPos(playerid, Player[playerid][Position][0], Player[playerid][Position][1], Player[playerid][Position][2]);
format(query, sizeof(query), "UPDATE accounts SET Name = '%s', Password = '%s', PlayerX = '%f', PlayerY = '%f', PlayerZ = '%f' WHERE Name = '%s'", pName, Player[playerid][Password], Player[playerid][Position][0], Player[playerid][Position][1], Player[playerid][Position][2], pName);
mysql_query(query);
printf("[server] Player ID %d (%s) has been saved into the database.", playerid, pName);
}
pawn Код:
[18:25:45] CMySQLHandler::Query(UPDATE accounts SET Name = 'Steve_Malcom', Password = '', PlayerX = '1962.481079', PlayerY = '1342.575927', PlayerZ = '15.4) - An error has occured. (Error ID: 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 ''15.4' at line 1)
pawn Код:
case 1:
{
if(response)
{
new query[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "INSERT INTO accounts VALUES ('%s', '%s')", pName, inputtext);
mysql_query(query);
SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered into the server!");
SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
pawn Код:
[18:25:23] CMySQLHandler::Query(INSERT INTO accounts VALUES ('Steve_Malcom', 'passhere')) - An error has occured. (Error ID: 1136, Column count doesn't match value count at row 1)