MySQL error 1064 - error in SQL syntax
#1

Alright i receive this error when i try to register account to my Mysql based playersystem

Code:
[11:33:54] CMySQLHandler::Query(INSERT INTO playerdata (user, password, score, money, level, vip, admin, kma, rank, faction, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('Kevin_Hawk', SHA1('test123'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Not Banned', 0, 0, 0, 0, 0, '127.0.0) - An error has occured. (Error ID: 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 ''127.0.0' at line 1)

[11:34:04] >> mysql_query( Connection handle: 1 )

[11:34:04] CMySQLHandler::Query(UPDATE playerdata SET score=0, money=0, level=0, vip=0, admin=0, kma=0, rank=0, faction=0, kills=0, deaths=0, muted=0, jailed=0, frozen=0, mutedtimes=0, jailedtimes=0, frozentimes=0, banned=0, bannedby='', logins=0, posx=155.438674, posy=-69.451934, posz=1.429687, posa=264.038055  WHERE user='Kevin) - An error has occured. (Error ID: 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 ''Kevin' at line 1)
Problem is that the account won't save...server creates the 'playerdata' table (if it does not exist) at the start normally...so i guess it is my MySQL_Register part that causes the problem..

Pawn codes:

OnGameModeInit
pawn Code:
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(40), score INT(20), money INT(20), level INT(20), vip INT(20), admin INT(20), kma INT(20), rank INT(20), faction INT(20), kills INT(20), deaths INT(20), muted INT(20), jailed INT(20), frozen INT(20), mutedtimes INT(20), jailedtimes INT(20), frozentimes INT(20), banned INT(20), bannedby VARCHAR(24), logins INT(20), posx INT(20), posy INT(20), posz INT(20), posa INT(20), IP VARCHAR(15) )");
    mysql_debug(1);
MySQL_Register Stock
pawn Code:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[350], pname[24], IP[25];
    new Bannedby[20];
    format(Bannedby, 20, "Not Banned");
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 25);
    format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, admin, kma, rank, faction, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, '%s')", pname, passwordstring, Bannedby, IP);
    mysql_query(query);
    SendMessage(playerid, "~g~Info: ~w~You have been registered on this server!");
    Logged[playerid] = 1;
    return 1;
}
It worked before nicely, not anymore :/
Reply
#2

The error practically tells you where to look. If you go there and look at it:
Code:
WHERE user='Kevin
You can see that the last two characters are cut off. Means that your string is not long enough. But have you considered using default values in your table? The only things you're inserting are name, password and ip.
Reply
#3

Thank you Vince and rep, checked login/register stocks once again and saw that the "saving string" was idd too short (forgot to check it probably ages ago when added some more stuff )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)