cache_insert_id is always 0
#1

pawn Код:
// under DIALOG_REGISTER
mysql_format(SQL, Query, sizeof(Query), "INSERT INTO `Accounts` (`Username`, `Password`) VALUES ('%e', '%e')", GetNameWithUnderscore(playerid), Player[playerid][Password]);
            mysql_tquery(SQL, Query, "OnPlayerRegisterAccount", "i", playerid);
pawn Код:
public OnPlayerRegisterAccount(playerid)
{
    Player[playerid][DatabaseID] = cache_insert_id();
    printf("[SQL] New account registered. Database ID: [%d]", cache_insert_id());

    new pIP[16], Query[255];
    GetPlayerIp(playerid, pIP, sizeof(pIP));
   
    mysql_format(SQL, Query, sizeof(Query), "UPDATE `accounts` SET `RegisterIP` = %s, \
        WHERE `DatabaseID` = %d"
, pIP, Player[playerid][DatabaseID]); // I'm also getting a MYSQL error here
    mysql_tquery(SQL, Query, "", "");

    AdvanceTutorial(playerid, 1);
    return 1;
}
cache_insert_id and Player[playerid][DatabaseID] always returns 0.

Halp pls (REP+)
Reply
#2

The column in the db should be set with AUTO_INCREMENT.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The column in the db should be set with AUTO_INCREMENT.
Thank you! I forgot to do that when I was setting up my db. Rookie mistake.

I'm going to test it. REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)