Error saving MySQL data -
Kireykin - 07.05.2018
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_string, sizeof(query_string), "%s `player_name` = '%s',", query_string, pInfo[playerid][pName]);
format(query_string, sizeof(query_string), "%s `password` = '%s'", query_string, pInfo[playerid][pPassword]);
format(query_string, sizeof(query_string), "%s `sex` = '%d',", query_string, pInfo[playerid][pSex]);
format(query_string, sizeof(query_string), "%s `rasa` = '%d',", query_string, pInfo[playerid][pRasa]);
format(query_string, sizeof(query_string), "%s `religia` = '%d',", query_string, pInfo[playerid][pReligia]);
format(query_string, sizeof(query_string), "%s WHERE `id` = '%d'", query_string, pInfo[playerid][pID]);
mysql_function_query(mysql_connect_ID, query_string, false, "", "");
return printf("Äàííûå àêêàóíòà ¹ %d (%s) áûëè ñîõðàíåíû.", pInfo[playerid][pID], pInfo[playerid][pName]);
}
MySQL Log:
PHP код:
[19:10:20 05/07/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 '`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] [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 '`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'")
Re: Error saving MySQL data -
FaLLenGirL - 07.05.2018
The errors appear because you didn't put "
, " in the right place like: < ... '%d'
,", query_string, ... >
Try this (
edited):
PHP код:
function SaveAccount( playerid )
{
new query_string[ 5000 ];
format( query_string, sizeof( query_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
`religia` = '%s' WHERE `id` = '%d'", pInfo[ playerid ][ pName ], pInfo[ playerid ][ pPassword ], pInfo[ playerid ][ pSex ], pInfo[ playerid ][ pRasa ],
pInfo[ playerid ][ pReligia ], pInfo[ playerid ][ pID ] );
mysql_function_query( mysql_connect_ID, query_string, false, "", "" );
printf( "Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu.", pInfo[ playerid ][ pID ], pInfo[ playerid ][ pName ] );
return 1;
}
Re: Error saving MySQL data -
Kireykin - 07.05.2018
Still does not save
PHP код:
[19:25:53 05/07/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' `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'")
Re: Error saving MySQL data -
FaLLenGirL - 07.05.2018
PHP код:
function SaveAccount( playerid )
{
new query_string[ 5000 ];
format( query_string, sizeof( query_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
`religia` = '%s' WHERE `id` = '%d'", pInfo[ playerid ][ pName ], pInfo[ playerid ][ pPassword ], pInfo[ playerid ][ pSex ], pInfo[ playerid ][ pRasa ],
pInfo[ playerid ][ pReligia ], pInfo[ playerid ][ pID ] );
mysql_function_query( mysql_connect_ID, query_string, false, "", "" );
return printf( "Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu.", pInfo[ playerid ][ pID ], pInfo[ playerid ][ pName ] );
}
Re: Error saving MySQL data -
Kireykin - 07.05.2018
MySQL log is clean.
But the data is still not saved.
PHP код:
stock CreateNewAccount(playerid, password[])
{
new query_string[1000+MAX_PLAYER_NAME-4+1000];
format(query_string, sizeof(query_string), "INSERT INTO `accounts` (`player_name`, `password`, `sex`, `rasa`, `religia`) VALUES ('%s', '%s', '%d', '%d', '%d')", pInfo[playerid][pName], password, pInfo[playerid][pSex], pInfo[playerid][pRasa], pInfo[playerid][pReligia]);
mysql_function_query(mysql_connect_ID, query_string, true, "UploadPlayerAccountNumber", "i", playerid);
format(query_string, sizeof(query_string),"{FFFFFF}Шаг 1/4 {FF4500}|{FFFFFF} Пароль для аккаунта %s успешно сохранён.", pInfo[playerid][pName]);
SendClientMessage(playerid, 0xFFFFFF00, query_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(playerid, 0xFFFFFF00, "{FF4500}| {FFFFFF}Вы успешно авторизировались!");
SpawnPlayer(playerid);
return 1;
}
/* ======================================================================== */
stock SaveAccount( playerid )
{
new query_string[ 5000 ];
format( query_string, sizeof( query_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
`religia` = '%s' WHERE `id` = '%d'", pInfo[ playerid ][ pName ], pInfo[ playerid ][ pPassword ], pInfo[ playerid ][ pSex ], pInfo[ playerid ][ pRasa ],
pInfo[ playerid ][ pReligia ], pInfo[ playerid ][ pID ] );
mysql_function_query( mysql_connect_ID, query_string, false, "", "" );
return printf("Данные аккаунта № %d (%s) были сохранены.", pInfo[playerid][pID], pInfo[playerid][pName]);
}
Re: Error saving MySQL data -
FaLLenGirL - 07.05.2018
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 SaveAccount( playerid )
{
new query_string[ 5000 ];
format( query_string, sizeof( query_string ), "UPDATE `accounts` SET `player_name` = '%s', `sex` = '%s', `rasa` = '%s', \
`religia` = '%s' WHERE `id` = '%d'", pInfo[ playerid ][ pName ], pInfo[ playerid ][ pPassword ], pInfo[ playerid ][ pSex ], pInfo[ playerid ][ pRasa ],
pInfo[ playerid ][ pReligia ], pInfo[ playerid ][ pID ] );
mysql_function_query( mysql_connect_ID, query_string, false, "", "" );
printf( "Дaннua aeeaунoa %d(%s) бuлe nоo?aнaнu.", pInfo[ playerid ][ pID ], pInfo[ playerid ][ pName ] );
return 1;
}
Re: Error saving MySQL data -
Kireykin - 07.05.2018
Same problem.
No changes.
The account is not saved, printing does not appear.
Re: Error saving MySQL data -
FaLLenGirL - 07.05.2018
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.
Re: Error saving MySQL data -
Kireykin - 07.05.2018
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_string, sizeof(query_string), "%s `player_name` = '%s',", query_string, pInfo[playerid][pName]);
format(query_string, sizeof(query_string), "%s `password` = '%s',", query_string, pInfo[playerid][pPassword]);
format(query_string, sizeof(query_string), "%s `sex` = '%d',", query_string, pInfo[playerid][pSex]);
format(query_string, sizeof(query_string), "%s `rasa` = '%d',", query_string, pInfo[playerid][pRasa]);
format(query_string, sizeof(query_string), "%s `religia` = '%d'", query_string, pInfo[playerid][pReligia]);
format(query_string, sizeof(query_string), "%s WHERE `id` = '%d'", query_string, pInfo[playerid][pID]);
mysql_function_query(mysql_connect_ID, query_string, false, "", "");
return printf("Данные аккаунта № %d (%s) были сохранены.", pInfo[playerid][pID], pInfo[playerid][pName]);
}