SA-MP Forums Archive
MySQL error - 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 error (/showthread.php?tid=652829)



MySQL error - Kireykin - 19.04.2018

Help please with the solution of the problem in MySQL

MySQL log:
[00:15:36 04/20/18] [ERROR] CMySQLQuery::Execute[] - (error #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 '`password` = '12345' `PosX` = '0.000000', `PosY` = '0.000000', `PosZ` = '0.00000' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Devreyk' `password` = '12345' `PosX` = '0.000000', `PosY` = '0.000000', `PosZ` = '0.000000', WHERE `id` = '0',")

Code:
PHP код:
stock SaveAccount(playerid)
{
    new 
query_string[(256)+(50+11)+(50+MAX_PLAYER_NAME)+(50+30)] = "UPDATE `accounts` SET";
    
format(query_stringsizeof(query_string), "%s `player_name` = '%s'"query_stringpInfo[playerid][pName]);
    
format(query_stringsizeof(query_string), "%s `password` = '%s'"query_stringpInfo[playerid][pPassword]);
    
format(query_stringsizeof(query_string), "%s `PosX` = '%f',"query_stringpInfo[playerid][Pos][0]);
    
format(query_stringsizeof(query_string), "%s `PosY` = '%f',"query_stringpInfo[playerid][Pos][1]);
    
format(query_stringsizeof(query_string), "%s `PosZ` = '%f',"query_stringpInfo[playerid][Pos][2]);
    
format(query_stringsizeof(query_string), "%s WHERE `id` = '%d',"query_stringpInfo[playerid][pID]);
    
mysql_function_query(mysql_connect_IDquery_stringfalse"""");
    
SavePos(playerid);
    
SaveInv(playerid);
    return 
1;




Re: MySQL error - AdamsLT - 19.04.2018

I think you might have missed two commas in your syntax. One after the player_name line, one after the password line. Also, you don't need the comma after Where.

So, "%s `player_name` = '%s'" would change to "%s `player_name` = '%s',"
and "%s `password` = '%s'" to "%s `password` = '%s',"
and then "%s WHERE `id` = '%d'," changes to "%s WHERE `id` = '%d'"


Re: MySQL error - Kireykin - 19.04.2018

Put commas about which you said, but the problem did not disappear.


Re: MySQL error - AdamsLT - 19.04.2018

Did the error message change at all? If it did, post it here.


Re: MySQL error - Kireykin - 19.04.2018

The error remained the same.

[00:45:21 04/20/18] [ERROR] CMySQLQuery::Execute[] - (error #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 'WHERE `id` = '0'' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Devreyk', `password` = '12345', `PosX` = '0.000000', `PosY` = '0.000000', `PosZ` = '0.000000', WHERE `id` = '0'")
[00:45:27 04/20/18] [ERROR] CMySQLQuery::Execute[] - (error #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 'WHERE `id` = '0'' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Devreyk', `password` = '12345', `PosX` = '0.000000', `PosY` = '0.000000', `PosZ` = '0.000000', WHERE `id` = '0'")


Re: MySQL error - AdamsLT - 19.04.2018

It's not the same tho. It moved to another spot. The error code remained the same but the syntax problem moved.

There is an extra comma after PosZ that you do not need.
Change "%s `PosZ` = '%f'," to "%s `PosZ` = '%f'"


Re: MySQL error - Kireykin - 19.04.2018

Thank you very much for the help. The player's position is not preserved, but I'll try to solve this problem myself.
Good luck.


Re: MySQL error - GTLS - 20.04.2018

you dont need to put float and numbers inside single quotes.