SA-MP Forums Archive
Yet another MSQL Problem.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Yet another MSQL Problem.. (/showthread.php?tid=353968)



Yet another MSQL Problem.. - Shockey HD - 25.06.2012

Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[500], pname[24], IP[16];
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 16);
    format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, IP,admin,faction,leader,cuffed,badge,accent,gender,skin,xchord, ychord, zchord,health,armor) VALUES('%s', SHA1('%s'),0, 0, '%s',0,0,0,0,0,0,0,299,1714,-1882,14,100,0)", pname, passwordstring, IP);
    mysql_query(query);
    SendClientMessage(playerid, -1, "You have been registered on this server!");
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Gender", "Male\nFemale", "Select", "");
    Logged[playerid] = 1; 
    return 1;
}
And im receiving the following error:

Код:
[04:07:35] CMySQLHandler::Query(INSERT INTO playerdata (user, password, score, money, IP,admin,faction,leader,cuffed,badge,accent,gender,skin,xchord, ychord, zchord,health,armor) VALUES('Nestea', SHA1('test'),0, 0, '127.0.0.1',0,0,0,0,0,0,0,0,299,1714,-1882,14,100,0)) - An error has occured. (Error ID: 1136, Column count doesn't match value count at row 1)



Re: Yet another MSQL Problem.. - dowster - 25.06.2012

You are giving it 1 too many values, you specify 18 colums and 19 values.
Код:
INSERT INTO playerdata (user, password, score, money, IP,admin,faction,leader,cuffed,badge,accent,gender,skin,xchord, ychord, zchord,health,armor) VALUES('%s', SHA1('%s'),0, 0, '%s',0,0,0,0,0,0,0,299,1714,-1882,14,100,0)
Should be:
Код:
INSERT INTO playerdata (user, password, score, money, IP,admin,faction,leader,cuffed,badge,accent,gender,skin,xchord, ychord, zchord,health,armor) VALUES('%s', SHA1('%s'),0, 0, '%s',0,0,0,0,0,0,299,1714,-1882,14,100,0)
I think i removed the right value, it was between the IP and SKIN ID columns.