SA-MP Forums Archive
MySql Updating format - Help please - 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 Updating format - Help please (/showthread.php?tid=493239)



MySql Updating format - Help please - Sledgehammer - 07.02.2014

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.


Re: MySql Updating format - Help please - FireCat - 07.02.2014

Make the query cells higher.

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


Re: MySql Updating format - Help please - judothijs - 07.02.2014

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


Re: MySql Updating format - Help please - Sledgehammer - 07.02.2014

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

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


Re: MySql Updating format - Help please - FireCat - 07.02.2014

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


Re: MySql Updating format - Help please - Sledgehammer - 07.02.2014

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)



Re: MySql Updating format - Help please - Sledgehammer - 07.02.2014

Bump


Re: MySql Updating format - Help please - Riddy - 07.02.2014

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.


Re: MySql Updating format - Help please - Konstantinos - 07.02.2014

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.


Re: MySql Updating format - Help please - Sledgehammer - 07.02.2014

pawn Код:
new query[200];