Error saving MySQL data
#1

Not save religion, skin and nationality.
Help me please.
PHP код:
stock SaveAccount(playerid)
{
    new 
query_string[(1000)+(1000+11)+(20+MAX_PLAYER_NAME)+(16+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 `sex` = '%d',"query_stringpInfo[playerid][pSex]);
    
format(query_stringsizeof(query_string), "%s `rasa` = '%d',"query_stringpInfo[playerid][pRasa]);
    
format(query_stringsizeof(query_string), "%s `religia` = '%d',"query_stringpInfo[playerid][pReligia]);
    
format(query_stringsizeof(query_string), "%s WHERE `id` = '%d'"query_stringpInfo[playerid][pID]);
    
mysql_function_query(mysql_connect_IDquery_stringfalse"""");
    return 
printf("Äàííûå àêêàóíòà ¹ %d (%s) áûëè ñîõðàíåíû."pInfo[playerid][pID], pInfo[playerid][pName]);

MySQL Log:
PHP код:
[19:10:20 05/07/18] [ERRORCMySQLQuery::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 '`sex` = '1', `rasa` = '0', `religia` = '5', WHERE `id` = '68'' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Devreyk', `password` = '12345' `sex` = '1', `rasa` = '0', `religia` = '5', WHERE `id` = '68'")
[19:10:23 05/07/18] [ERRORCMySQLQuery::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 '`sex` = '1', `rasa` = '0', `religia` = '1', WHERE `id` = '69'' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Dylan_Brown', `password` = 'пгорорроро' `sex` = '1', `rasa` = '0', `religia` = '1', WHERE `id` = '69'") 
Reply
#2

The errors appear because you didn't put " , " in the right place like: < ... '%d',", query_string, ... >
Try this (edited):

PHP код:
function SaveAccountplayerid )
{
    new 
query_string5000 ];
    
formatquery_stringsizeofquery_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
    `religia` = '%s' WHERE `id` = '%d'"
pInfoplayerid ][ pName ], pInfoplayerid ][ pPassword ], pInfoplayerid ][ pSex ], pInfoplayerid ][ pRasa ],
     
pInfoplayerid ][ pReligia ], pInfoplayerid ][ pID ] );
    
mysql_function_querymysql_connect_IDquery_stringfalse"""" );
    
    
printf"Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu."pInfoplayerid ][ pID ], pInfoplayerid ][ pName ] );
    
    return 
1;

Reply
#3

Still does not save
PHP код:
[19:25:53 05/07/18] [ERRORCMySQLQuery::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' `sex` = '1' `rasa` = '0' `religia` = '4' WHERE `id` = '70'' at line 1 (Query: "UPDATE `accounts` SET `player_name` = 'Devreyk' `password` = '12345' `sex` = '1' `rasa` = '0' `religia` = '4' WHERE `id` = '70'") 
Reply
#4

PHP код:
function SaveAccountplayerid )
{
    new 
query_string5000 ];
    
formatquery_stringsizeofquery_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
    `religia` = '%s' WHERE `id` = '%d'"
pInfoplayerid ][ pName ], pInfoplayerid ][ pPassword ], pInfoplayerid ][ pSex ], pInfoplayerid ][ pRasa ],
     
pInfoplayerid ][ pReligia ], pInfoplayerid ][ pID ] );
    
mysql_function_querymysql_connect_IDquery_stringfalse"""" );
    
    return 
printf"Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu."pInfoplayerid ][ pID ], pInfoplayerid ][ pName ] );

Reply
#5

MySQL log is clean.
But the data is still not saved.
PHP код:
stock CreateNewAccount(playeridpassword[])
{
    new 
query_string[1000+MAX_PLAYER_NAME-4+1000];
    
format(query_stringsizeof(query_string), "INSERT INTO `accounts` (`player_name`, `password`, `sex`, `rasa`, `religia`) VALUES ('%s', '%s', '%d', '%d', '%d')"pInfo[playerid][pName], passwordpInfo[playerid][pSex], pInfo[playerid][pRasa], pInfo[playerid][pReligia]);
    
mysql_function_query(mysql_connect_IDquery_stringtrue"UploadPlayerAccountNumber""i"playerid);
    
format(query_stringsizeof(query_string),"{FFFFFF}Шаг 1/4 {FF4500}|{FFFFFF} Пароль для аккаунта %s успешно сохранён."pInfo[playerid][pName]);
    
SendClientMessage(playerid0xFFFFFF00query_string);
    return 
1;
}
forward UploadPlayerAccount(playerid);
public 
UploadPlayerAccount(playerid)
{
    
pInfo[playerid][pID] = cache_get_field_content_int(0"id"mysql_connect_ID);
       
pInfo[playerid][pSex] = cache_get_field_content_int(0"sex"mysql_connect_ID);
    
pInfo[playerid][pRasa] = cache_get_field_content_int(0"rasa"mysql_connect_ID);
       
pInfo[playerid][pReligia] = cache_get_field_content_int(0"religia"mysql_connect_ID);
    
SendClientMessage(playerid0xFFFFFF00"{FF4500}| {FFFFFF}Вы успешно авторизировались!");
    
SpawnPlayer(playerid);
    return 
1;
}
/*  ========================================================================  */
stock SaveAccountplayerid )
{
    new 
query_string5000 ];
    
formatquery_stringsizeofquery_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
    `religia` = '%s' WHERE `id` = '%d'"
pInfoplayerid ][ pName ], pInfoplayerid ][ pPassword ], pInfoplayerid ][ pSex ], pInfoplayerid ][ pRasa ],
    
pInfoplayerid ][ pReligia ], pInfoplayerid ][ pID ] );
    
mysql_function_querymysql_connect_IDquery_stringfalse"""" );
    return 
printf("Данные аккаунта № %d (%s) были сохранены."pInfo[playerid][pID], pInfo[playerid][pName]);

Reply
#6

Maybe you reset the variables after the database load them.
I don't see something wrong at the code that i gave to you now. Either at your code that you posted.
Also try again this:

PHP код:
function SaveAccountplayerid )
{
    new 
query_string5000 ];
    
formatquery_stringsizeofquery_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
    `religia` = '%s' WHERE `id` = '%d'"
pInfoplayerid ][ pName ], pInfoplayerid ][ pPassword ], pInfoplayerid ][ pSex ], pInfoplayerid ][ pRasa ],
     
pInfoplayerid ][ pReligia ], pInfoplayerid ][ pID ] );
    
mysql_function_querymysql_connect_IDquery_stringfalse"""" );
    
    
printf"Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu."pInfoplayerid ][ pID ], pInfoplayerid ][ pName ] );
    
    return 
1;

Reply
#7

Same problem.
No changes.
The account is not saved, printing does not appear.
Reply
#8

Show me the code where you use "SaveAccount" stock.
And change "stock" with "function" because it is a function that saves the dates not a stock.
Reply
#9

Many thanks for your help, I solved the problem myself.
Arranged commas as follows and the account is saved successfully.
PHP код:
/*  ========================================================================  */
stock SaveAccount(playerid)
{
    new 
query_string[(1000)+(1000+11)+(100+MAX_PLAYER_NAME)+(100+100)] = "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 `sex` = '%d',"query_stringpInfo[playerid][pSex]);
    
format(query_stringsizeof(query_string), "%s `rasa` = '%d',"query_stringpInfo[playerid][pRasa]);
    
format(query_stringsizeof(query_string), "%s `religia` = '%d'"query_stringpInfo[playerid][pReligia]);
    
format(query_stringsizeof(query_string), "%s WHERE `id` = '%d'"query_stringpInfo[playerid][pID]);
    
mysql_function_query(mysql_connect_IDquery_stringfalse"""");
    return 
printf("Данные аккаунта № %d (%s) были сохранены."pInfo[playerid][pID], pInfo[playerid][pName]);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)