Saving to DB from Player enum. Possible cause of fault?
#3

Quote:
Originally Posted by mkr
It seems to me that the problem is you aren't updating pAccountID with the ID that they're assigned in the database.
Indeed.

Quote:
Originally Posted by mkr
AccountID needs to be the primary key in your table
Is now.

Quote:
Originally Posted by mkr
and after your insert statement you should set Player[playerid][pAccountID] to mysql_insert_row()
Hmm.. possible if I could grab an example off ya? I'm not sure what plugin I am using


Quote:
Originally Posted by mkr
each one of those queries is trying to update WHERE AccountID = 0, which isn't going to do anything.
Any ideas how to get the AccountId for the player then?
Maybe like this?
pawn Код:
stock SavePlayerAccount(playerid)
{
    if(IsPlayerConnected(playerid))
    {
    new x;
    new EscapedName[MAX_PLAYER_NAME];
    mysql_real_escape_string(GetName(playerid), EscapedName);
    //UpdatePlayerVariables(playerid);
    while(mysql_retrieve_row())
    {
        mysql_get_field("AccountID", DataResult);
        x = strval(DataResult);
    }
        if(CheckExist(playerid) == 0)
        {
            format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
            mysql_query(query);
        }
        format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
        Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
        Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
        Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],x);
        mysql_query(query);
        SaveContacts(playerid);
    }
}
Quote:
Originally Posted by mkr
You should echo those queries to the console just to be sure. Having phpmyadmin is nice because you can just feed them into it and it'll cough out any error messages that the queries generate.
Running my Server through putty and doesn't seem to show the server logs (Linux Server)



Thanks for your help so far.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)