error 033: array must be indexed
#1

pawn Код:
new Leader[41];
new Leadername[41][MAX_PLAYER_NAME];

public LeaderMySQLFetchAcctRecord(sqlplayerid, sqlresult[])
{
    new query[64];
    format(query, sizeof(query), "SELECT * FROM leaders WHERE id = %d LIMIT 1", sqlplayerid);
    mysql_query(query);
    mysql_store_result();
    if(mysql_fetch_row(sqlresult)==1)
    {
        return 1;
    }
    return 0;
}

public LoadLeader()
{
    MySQLCheckConnection();
    new Data[1024];
    new Field[1024];
    format(Data, sizeof(Data), "SELECT * FROM `leaders` WHERE `id` = '1'");
    mysql_query(Data);
    mysql_store_result();
    LeaderMySQLFetchAcctRecord(1, Data);
    if(mysql_fetch_row_format(Data, "|"))
    {
        mysql_fetch_field_row(Data, "Leader1"); Leader[1] = strval(Data);
        mysql_fetch_field_row(Data, "Leader2"); Leader[2] = strval(Data);
        mysql_fetch_field_row(Data, "Leader3"); Leader[3] = strval(Data);
        mysql_fetch_field_row(Data, "Leader4"); Leader[4] = strval(Data);
        mysql_fetch_field_row(Data, "Leader5"); Leader[5] = strval(Data);
        mysql_fetch_field_row(Data, "Leader6"); Leader[6] = strval(Data);
        mysql_fetch_field_row(Data, "Leader7"); Leader[7] = strval(Data);
        mysql_fetch_field_row(Data, "Leader8"); Leader[8] = strval(Data);
        mysql_fetch_field_row(Data, "Leader9"); Leader[9] = strval(Data);
        mysql_fetch_field_row(Data, "Leader10"); Leader[10] = strval(Data);
        mysql_fetch_field_row(Data, "Leader11"); Leader[11] = strval(Data);
        mysql_fetch_field_row(Data, "Leader12"); Leader[12] = strval(Data);
        mysql_fetch_field_row(Data, "Leader13"); Leader[13] = strval(Data);
        mysql_fetch_field_row(Data, "Leader14"); Leader[14] = strval(Data);
        mysql_fetch_field_row(Data, "Leader15"); Leader[15] = strval(Data);
        mysql_fetch_field_row(Data, "Leader16"); Leader[16] = strval(Data);
        mysql_fetch_field_row(Data, "Leader17"); Leader[17] = strval(Data);
        mysql_fetch_field_row(Data, "LeaderName1"); Leadername[1] = strmid(Leadername[1], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName2"); Leadername[2] = strmid(Leadername[2], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName3"); Leadername[3] = strmid(Leadername[3], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName4"); Leadername[4] = strmid(Leadername[4], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName5"); Leadername[5] = strmid(Leadername[5], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName6"); Leadername[6] = strmid(Leadername[6], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName7"); Leadername[7] = strmid(Leadername[7], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName8"); Leadername[8] = strmid(Leadername[8], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName9"); Leadername[9] = strmid(Leadername[9], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName10"); Leadername[10] = strmid(Leadername[10], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName11"); Leadername[11] = strmid(Leadername[11], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName12"); Leadername[12] = strmid(Leadername[12], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName13"); Leadername[13] = strmid(Leadername[13], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName14"); Leadername[14] = strmid(Leadername[14], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName15"); Leadername[15] = strmid(Leadername[15], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName16"); Leadername[16] = strmid(Leadername[16], Data, 0, strlen(Data)-1, 255);
        mysql_fetch_field_row(Data, "LeaderName17"); Leadername[17] = strmid(Leadername[17], Data, 0, strlen(Data)-1, 255);
    }
    mysql_free_result();
    return 1;
}
Код:
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17718) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17719) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17720) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17721) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17722) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17723) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17724) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17725) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17726) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17727) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17728) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17729) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17730) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17731) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17732) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17733) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17734) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17736) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17738) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17740) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17742) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17744) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17746) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17748) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17750) : error 033: array must be indexed (variable "Leadername")
C:\Documents and Settings\CMDX\Desktop\samp03dsvr_R2_win32\gamemodes\gm.pwn(17752) : error 033: array must be indexed (variable "Leadername")
Reply
#2

There's a whole lot wrong with that code.

First of all, you forgot to call mysql_free_result in your LeaderMySQLFetchAcctRecord function. Second, strmid doesn't return a value, so you can't use it that way. Third, if you intend to store a string, then why not load it in the correct variable in the first place?

pawn Код:
mysql_fetch_field_row(Leadername[1], "LeaderName1");
Fourth, make sure your "Leadername" variable is two-dimensional array like this:
pawn Код:
new Leadername[18][MAX_PLAYER_NAME];
Fifth, array indices start at 0, not 1.
Reply
#3

Thank you.

+Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)