Mysql Destination size too small
#1

I guess the problem is here?
No errors its just doesnt register player to database
pawn Код:
case dregister:
        {
            if(!response) return Kick(playerid);
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
     
            new query[300];
            WP_Hash(pinfo[playerid][Password], 129, inputtext);
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`,\
            `Score`, `Banned`, `Cuffed`, `Muted`, `Jailed`, `JailTime`, `Drugs`, `DrugAmount`, `Robskill`, `Hitmanskill`, `Terskill`, `TotalRobs`\
            `Skin`, `Team`, `Kills`, `Deaths`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"
, Name[playerid], pinfo[playerid][Password], IP[playerid]);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
            pinfo[playerid][Registered] = 1;
mysql_debug
Код:
[20:29:25] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[20:29:25] [DEBUG] Calling callback "OnAccountCheck"..
[20:29:25] [DEBUG] cache_get_data - connection: 1
[20:29:25] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[20:29:34] [DEBUG] mysql_format - connection: 1, len: 300, format: "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`,`Score`, `Banned`, `Cuffed`..."
[20:29:34] [ERROR] mysql_format - destination size is too small
[20:29:34] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `V", callback: "OnAccountRegister", format: "i"
[20:29:34] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - starting query execution
[20:29:34] [ERROR] CMySQLQuery::Execute[OnAccountRegister] - (error #1064) 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 '' at line 1
[20:29:34] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - error will be triggered in OnQueryError
[20:29:42] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `players` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f,`Score` =%d, `Banned` =%d, `Cuffed` =%d, ..."
[20:29:42] [ERROR] mysql_format - destination size is too small
[20:29:42] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `Admin`=0, `VIP`=0, `Money`=0, `posX`=-3.20", callback: "(null)", format: "(null)"
[20:29:42] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[20:29:42] [ERROR] CMySQLQuery::Execute[] - (error #1064) 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 '`Cuf' at line 1
[20:29:42] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
Reply
#2

new query[512];
Reply
#3

Your query variable is too small.
The password alone consumes 129 characters, and your query is only 300 characters long.
Just counted in Notepad after filling in the maximum amount of data (size of password 130 chars, and 24 chars for playername, as well as 16 chars for the IP),
and it's 534 characters long, so "new Query[540];" will be enough.

Also, you're missing a comma after "TotalRobs".

Suggestion: for all fields that have the default value of 0, edit your tables so these fields have "0" as default value.
Then you don't need to add them to your query, as MySQL will fill them in automatically when you don't supply them.
Your query can thus be made alot smaller, as you would only need to supply the player's name, password and IP.

It will also be easier to find errors like this.

Instead of this:
pawn Код:
"INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`,\
            `Score`, `Banned`, `Cuffed`, `Muted`, `Jailed`, `JailTime`, `Drugs`, `DrugAmount`, `Robskill`, `Hitmanskill`, `Terskill`, `TotalRobs`\
            `Skin`, `Team`, `Kills`, `Deaths`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"
, Name[playerid], pinfo[playerid][Password], IP[playerid]);
It would become this:
pawn Код:
"INSERT INTO `players` (`Username`, `Password`, `IP`) VALUES ('%e', '%s', '%s')", Name[playerid], pinfo[playerid][Password], IP[playerid]);
All other values are 0 anyway, so just set your tables to have "0" as default value for them.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)