MySQL error
#1

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;

Reply
#2

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'"
Reply
#3

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

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

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'")
Reply
#6

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'"
Reply
#7

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)