MYSQL weapon save problem
#1

Код:
 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? :/
Reply
#2

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.
Reply
#3

Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)