Data Not Loading (MySQL R7)
#1

After logging into the server (Successfully) the data is not loaded, i'm pretty new to R7 so any help would be awesome.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

    if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            new string[600], HashedPW[145];
            WP_Hash(HashedPW, sizeof (HashedPW), inputtext);

            printf("Password Buffer: %s", HashedPW);
            format(string,sizeof(string),"SELECT cPassword FROM `character_data` WHERE `cPassword` = '%s'", HashedPW);
            mysql_function_query(MySQL_Connection, string, true, "LoadCharacterData","i", playerid);       

        } else {
            Kick(playerid);
        }
    }

}

public LoadCharacterData(playerid)
{
    new fields, rows, fetch[256];
    cache_get_data(rows, fields, MySQL_Connection);

    print("Loading Data");
    if(rows !=0)
    {
            print("Loading Character Stats");
            cache_get_field_content(rows, "CharacterID", fetch, MySQL_Connection);
            CharacterInfo[playerid][CharacterID] = strval(fetch);
            cache_get_field_content(rows, "CharacterName", fetch, MySQL_Connection);
            format(CharacterInfo[playerid][cCharacterName], MAX_PLAYER_NAME, "%s", fetch);
            printf("Character Name: %s", CharacterInfo[playerid][cCharacterName]);
            cache_get_field_content(rows, "cPassword", fetch, MySQL_Connection);
            format(CharacterInfo[playerid][cPassword], 126, "%s", fetch);                  
            cache_get_field_content(rows, "cStaffName", fetch, MySQL_Connection);
            format(CharacterInfo[playerid][cStaffName], 25, "%s", fetch);
            cache_get_field_content(rows, "cStaffLevel", fetch, MySQL_Connection);
            CharacterInfo[playerid][cStaffLevel] = strval(fetch);
            cache_get_field_content(rows, "cHelperLevel", fetch, MySQL_Connection);
            CharacterInfo[playerid][cHelperLevel] = strval(fetch);  
            cache_get_field_content(rows, "cFaction", fetch, MySQL_Connection);
            CharacterInfo[playerid][cFaction] = strval(fetch);
            cache_get_field_content(rows, "cFactionRank", fetch, MySQL_Connection);
            CharacterInfo[playerid][cFactionRank] = strval(fetch);  
            cache_get_field_content(rows, "cFactionBadge", fetch, MySQL_Connection);
            format(CharacterInfo[playerid][cFactionBadge], 10, "%s", fetch);  

            cache_get_field_content(rows, "Character_X",fetch, MySQL_Connection);
            CharacterInfo[playerid][Character_X] = floatstr(fetch);
            cache_get_field_content(rows, "Character_Y",fetch, MySQL_Connection);
            CharacterInfo[playerid][Character_Y] = floatstr(fetch);
            cache_get_field_content(rows, "Character_Z",fetch, MySQL_Connection);
            CharacterInfo[playerid][Character_Z] = floatstr(fetch);                    
            cache_get_field_content(rows, "Character_R",fetch, MySQL_Connection);
            CharacterInfo[playerid][Character_R] = floatstr(fetch);        

            cache_get_field_content(rows, "cHasRadio", fetch, MySQL_Connection);
            CharacterInfo[playerid][cHasRadio] = strval(fetch);
            cache_get_field_content(rows, "cRadioPower", fetch, MySQL_Connection);
            CharacterInfo[playerid][cRadioPower] = strval(fetch);
            cache_get_field_content(rows, "cRadioFrequency", fetch, MySQL_Connection);
            CharacterInfo[playerid][cRadioFrequency] = strval(fetch);                                                                                      
            cache_get_field_content(rows, "cDrivingLicense", fetch, MySQL_Connection);
            CharacterInfo[playerid][cDrivingLicense] = strval(fetch);
            cache_get_field_content(rows, "cWeaponsLicense", fetch, MySQL_Connection);
            CharacterInfo[playerid][cWeaponsLicense] = strval(fetch);
            cache_get_field_content(rows, "cTruckingLicense", fetch, MySQL_Connection);
            CharacterInfo[playerid][cTruckingLicense] = strval(fetch);
            cache_get_field_content(rows, "cCookies", fetch, MySQL_Connection);
            CharacterInfo[playerid][cCookies] = strval(fetch);
            cache_get_field_content(rows, "cGoldNuggets", fetch, MySQL_Connection);
            CharacterInfo[playerid][cGoldNuggets] = strval(fetch);
            cache_get_field_content(rows, "cStaffJailed", fetch, MySQL_Connection);
            CharacterInfo[playerid][cStaffJailed] = strval(fetch);
            cache_get_field_content(rows, "cStaffJailedTime", fetch, MySQL_Connection);
            CharacterInfo[playerid][cStaffJailedTime] = strval(fetch);  

    } else {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to {EN}", "Please provide the password you provided where you registered.", "Continue", "Quit");
    }  
    return 1;
}
Reply
#2

Check MySQL error log.

And the server is properly connected?
Reply
#3

You can only retrieve the data that you selected in the first place.
Reply
#4

change this:

pawn Код:
format(string,sizeof(string),"SELECT cPassword FROM `character_data` WHERE `cPassword` = '%s'", HashedPW);
to this:

pawn Код:
format(string,sizeof(string),"SELECT * FROM `character_data` WHERE `cPassword` = '%s'", HashedPW);
By using the asterisks symbol, it will allow you to select all data from the table.
Reply
#5

That's for your responses, I realised what I did wrong she. I got in bed......
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)