MYSQL errors
#1

I have two mysql errors and I can't find the mistake in it.

Код:
Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''15.48225' at line 1.
Saving
pawn Код:
stock SavePlayer(playerid)
{
    new query[126], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerPos(playerid, PlayerS[playerid][Position][0], PlayerS[playerid][Position][1], PlayerS[playerid][Position][2]);
    format(query, sizeof(query), "UPDATE accounts SET Name = '%s', Password = '%s', PlayerX = '%f', PlayerY = '%f', PlayerZ = '%f' WHERE Name = '%s'", pName, PlayerS[playerid][Password], PlayerS[playerid][Position][0], PlayerS[playerid][Position][1], PlayerS[playerid][Position][2], pName);
    mysql_query(query);
}
Reply
#2

pawn Код:
new query[126]
//to
new query[256]
Floats have 6 digits after dot, your query alone (including format specifiers) is 114 chars long
Reply
#3

Well one error is gone, but I still got one.
Код:
Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
Reply
#4

as i can see you forgot to put ; at the end. and you don't need to update/save player name and password that's kind off useless so try this code if it will work

pawn Код:
stock SavePlayer(playerid)
{
    new query[126], pName[24];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerPos(playerid, PlayerS[playerid][Position][0], PlayerS[playerid][Position][1], PlayerS[playerid][Position][2]);
    format(query, sizeof(query), "UPDATE `accounts` SET `PlayerX` = '%f', `PlayerY` = '%f', `PlayerZ` = '%f' WHERE `Name` = '%s';", PlayerS[playerid][Position][0], PlayerS[playerid][Position][1], PlayerS[playerid][Position][2], pName);
    mysql_query(query);
}
Reply
#5

I just saw that the error is coming when I click Register.
There is something wrong in this code:
pawn Код:
new query[256], 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, -1, "Registered!");
                SetSpawnInfo(playerid, 1, 299, 1, 2, 3, 1, 1, 999, 1, 999, 1, 999);
                SpawnPlayer(playerid);
Reply
#6

LOL!, you are missing Columns you want to add INSERT INTO `accounts` (`Name`, `Password`) VALUES ('%s', '%s')
Reply
#7

You can choose not to specify columns, but then you have to provide _all_ of them. So if there were id, name, password, then it'd be: "INSERT INTO `accounts` VALUES(null, '%s', '%s'). There is also insert set (like with update) syntax
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)