MySql Updating format - Help please
#1

MySql Help


Hello,

I have encounter a problem on updating my MySql. I've been converting from Y_INI to MySql recently after a change off mind. I'm not really experienced, but I am still learning it. I have came here for some help. I have searched SA-MP forums, but the post I found, were pointless.

pawn Код:
format(query, sizeof(query), "UPDATE accounts SET Name = '%s', Password = '%s', Cash = %d, Admin = %d, Kills = %d, Deaths = %d, Skin = %d, DriversLic = %d, Mute = %d WHERE Faction = %d LIMIT 1", GetName(playerid), PlayerInfo[playerid][pPass], GetPlayerMoney(playerid), PlayerInfo[playerid][pAdmin],
    PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pDriverslic], PlayerInfo[playerid][pMute], PlayerInfo[playerid][pFaction]);
    mysql_query(query);
Debug:
Код:
[20:15:22] CMySQLHandler::Query(UPDATE accounts SET Name = 'Death', Password = 'test', Cash = 2000, Admin = 10, Kills = 0, Deaths = 9, Skin = 285, DriversLic = 0, Mute = 0 WHERE Faction = ) - 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 '' at line 1)

[20:15:22] >> mysql_query( Connection handle: 1 )

[20:15:22] CMySQLHandler::Query(UPDATE accounts SET Color = 0, Accent = 'none', PosX = '1543.220458', PosY = '-1628.804443', PosZ = '13.382812, Angle = '0.000000', Interior = 0 WHERE Virtual-) - 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 '0.000000', Interior = 0 WHERE Virtual-' at line 1)
Is there a way to fix this? I will be giving reputation points, if you attempt to help me as a thank you.
Reply
#2

Make the query cells higher.

For example 200. (in this case, because player information is always plenty of values)
Reply
#3

Try to be consequent on your programming grammar.
SQL likes it when you put quotation marks around variables and their values.
Try putting it on all of them.

Hope this sorts it out for you
Reply
#4

I've already done this, but its still doing.

EDIT: I will try putting the quotation marks around it now
Reply
#5

If you have the PlayerInfo[playerid][pFaction] NULL, then of course it will give an error!
Try making it '0' before formatting the query.
Reply
#6

I've changed anything that was 'NULL' to a defult number (I.e - 1). I have used quotation marks around the variables yet I still having the same problems. I've expanded the query to 200.

EDIT:

Код:
[21:37:01] CMySQLHandler::Query(UPDATE accounts SET 'Name' = 'death', 'Password' = 'test', 'Cash' = '2000', 'Admin' = '10', 'Kills' = '1', 'Deaths' = '9', 'Skin' = '285', 'DriversLic' = '1', 'Mute' = '1' WHERE 'Faction' = '1') - 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 ''Name' = 'death', 'Password' = 'test', 'Cash' = '2000', 'Admin' = '10', 'Kills' ' at line 1)
Reply
#7

Bump
Reply
#8

Don't bump, it's not nice. Anyways, you don't have to put '' around %d, but look at, also, you have to use graves (` or backtick) around field names.
Reply
#9

Quote:
Originally Posted by Death1300
Посмотреть сообщение
I've changed anything that was 'NULL' to a defult number (I.e - 1). I have used quotation marks around the variables yet I still having the same problems. I've expanded the query to 200.

EDIT:

Код:
[21:37:01] CMySQLHandler::Query(UPDATE accounts SET 'Name' = 'death', 'Password' = 'test', 'Cash' = '2000', 'Admin' = '10', 'Kills' = '1', 'Deaths' = '9', 'Skin' = '285', 'DriversLic' = '1', 'Mute' = '1' WHERE 'Faction' = '1') - 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 ''Name' = 'death', 'Password' = 'test', 'Cash' = '2000', 'Admin' = '10', 'Kills' ' at line 1)
Post the query too.
Reply
#10

pawn Код:
new query[200];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)