Mysql doesn't save
#1

PHP код:
stock SaveAccount(playerid) { 
        if(
gPlayerLogged[playerid] == 1) { 
            
CheckMySQLConnection(); 
            new 
query[300];
              
format(querysizeof(query), "UPDATE `Accounts` SET `Nickname` = '%s', `Password` = '%s', `AdminLevel` = '%d', `Vip` = '%d', `Banned` = '%d', `Muted` = '%d', `MutedTime` = '%d', `Skin` = '%d', `Score` = '%d', `Level` = '%d', `EXP` = '%d', `Money` = '%d' WHERE `ID` = '%i'",
            
playerVariable[playerid][Name],
            
playerVariable[playerid][Password],
            
playerVariable[playerid][AdminLevel],
            
playerVariable[playerid][Vip],
            
playerVariable[playerid][Banned],
            
playerVariable[playerid][Muted],
            
playerVariable[playerid][MutedTime],
            
playerVariable[playerid][Skin],
            
playerVariable[playerid][Score],
            
playerVariable[playerid][Level],
            
playerVariable[playerid][Exp],
            
playerVariable[playerid][Money],
            
playerVariable[playerid][ID]);
            
printf("%s",query);
            
mysql_query(query); 
        }
        return 
1;

Quote:

UPDATE `Accounts` SET `Nickname` = '23', `Password` = '', `AdminLevel` = '1', `Vip` = '0', `Banned` = '0', `Muted` = '0', `MutedTime` = '0', `Skin` = '0', `Score` = '0', `Level` = '0', `EXP` = '50', `Money` = '100' WHERE `ID` = '123456'

Log is completely wrong, Nickname should be Privies, ID - 23 and pass - 123456

Maybe something wrong with my LoadAcc?
PHP код:
stock LoadAccount(playeridpassword[]) {
        new    
query[128],
        
sqlpass[32],
        
result[5+24+64],
        
dialog[128];
        
mysql_real_escape_string(passwordsqlpass);
//        format(query, sizeof(query), "SELECT ID, Name, Password FROM `Accounts` WHERE `Password` = '%s' AND `ID` = '%i'", sqlpass, playerVariable[playerid][ID]);
        
format(querysizeof(query), "SELECT Password,ID FROM `Accounts` WHERE `Password` = '%s' AND `ID` = '%i'"sqlpassplayerVariable[playerid][ID], playerVariable[playerid][Name]    );
        
mysql_query(query);
        
mysql_store_result(); 
        if(
mysql_num_rows() == 1) { 
        
mysql_fetch_row_format(result"|");
        
sscanf(result"p<|>is[24]s[32]"//
        
playerVariable[playerid][Name],
        
playerVariable[playerid][Password],
        
playerVariable[playerid][ID]);
           
gPlayerLogged[playerid] = 1;
        
mysql_free_result(); 
        return 
1;
        }
        else { 
// Мы ввели неверный пароль.
            
if(playerVariable[playerid][WrongPassword] == 3) {
            
SendClientMessage(playeridCOLOR_LIGHTRED"Вы 3 раза ввели неверный пароль и были отключены от сервера.");
            
Kick(playerid);
            return 
1;
            }
            
playerVariable[playerid][WrongPassword] ++;
            
format(dialogsizeof(dialog),
            
"Вы ввели неверный пароль.\n\
            У Вас осталось %d/3 попыток ввода."
playerVariable[playerid][WrongPassword]);
            
ShowPlayerDialog(playeridDIALOG_WRONGPASDIALOG_STYLE_MSGBOX"Ошибка."dialog"Повтор""Отмена");
        }
        return 
1;

Reply
#2

Omg! I understood.

sscanf(result, "p<|>s[24]s[32]i", - solution
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)