SA-MP Forums Archive
MYSQL weapon save 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: MYSQL weapon save problem (/showthread.php?tid=614430)



MYSQL weapon save problem - kexy96 - 08.08.2016

Код:
 EID:1064 >> ERRMSG: 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 '' at line 1 >> ERRCLBK: WeapOnAccountRegister >> ERRQRY: INSERT INTO `playerweaps` (`Username`,`Weap0`,`AWeap0`,`Weap1`,`AWeap1`,`Weap2`,`AWeap2`,`Weap3`,`AWeap3`,`Weap4`,`AWeap4`,`Weap5`,`AWeap5`,`Weap6`,`AWeap6`,`Weap7`,`AWeap7`,`Weap8`,`AWeap8`,`Weap9`,


Код:
forward WeapOnAccountCheck(playerid);
public WeapOnAccountCheck(playerid)
{
    new rows, fields;
    new query[200];
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        pData[playerid][pID] = cache_get_field_content_int(0, "UserID");
        mysql_format(mysql, query, sizeof(query), "SELECT * FROM `playerweaps` WHERE `Username` = '%e' LIMIT 1", PlayerName(playerid));
        mysql_tquery(mysql, query, "WeapOnAccountLoad", "i", playerid);
    }
    else
    {
        	mysql_format(mysql, query, sizeof(query), "INSERT INTO `playerweaps` (`Username`,`Weap0`,`AWeap0`,`Weap1`,`AWeap1`,`Weap2`,`AWeap2`,`Weap3`,`AWeap3`,`Weap4`,`AWeap4`,`Weap5`,`AWeap5`,`Weap6`,`AWeap6`,`Weap7`,`AWeap7`,`Weap8`,`AWeap8`,`Weap9`,`AWeap9`,`Weap10`,`AWeap10`,`Weap11`,`AWeap11`,`Weap12`,`AWeap12`) VALUES ('%e',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,0)", PlayerName(playerid));
            mysql_tquery(mysql, query, "WeapOnAccountRegister", "i", playerid);
    }
    return 1;
}
What's the problem? :/


Re: MYSQL weapon save problem - AndySedeyn - 08.08.2016

a) You should read about the DEFAULT clause.
b) You could easily normalize that table (see Vince's tutorials in my signature for more info on that).

And to answer your actual problem: that formatted query is longer than 200 characters.


Re: MYSQL weapon save problem - kexy96 - 08.08.2016

Thank you!