problem loading stats with mysql
#1

hello im new using sql and im trying to load stats when someone enter to the server but i got this error

error 075: input line too long (after substitutions)

here is the code

Quote:

new line[750],idata[5][50],idata2[2],data[26],weap[13],ammo[13];
if(mysql_fetch_row(line))
{
sscanf(line,"p<|>s[50]s[50]s[50]s[50]s[50]dddffffddffddddddddddddddddddddddddddddddddddddddd dddd",idata[0],idata[1],idata[2],idata[3],idata[4],idata2[0],idata2[1],
data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],
weap[0],weap[1],weap[2],weap[3],weap[4],weap[5],weap[6],weap[7],weap[8],weap[9],weap[10],weap[11],weap[12],
ammo[0],ammo[1],ammo[2],ammo[3],ammo[4],ammo[5],ammo[6],ammo[7],ammo[8],ammo[9],ammo[10],ammo[11],ammo[12],
data[14],data[15],data[16],data[17],data[18]data[19],data[20],data[21],data[22],data[23],data[24],
data[25]);
}

what can i do?
Reply
#2

I think the eight line is bit too long.
Reply
#3

sscanf fails at long data, I personaly use this method.

pawn Код:
LoadPlayer(playerid)
{
    new Data[2048],key[256],idx,Names[24];
    GetPlayerName(playerid,Names,sizeof(Names));
    mysql_real_escape_string(Names,Names);
    mysql_queryF( "SELECT * FROM `users` WHERE `user_name` = '%s'",Names);
    mysql_store_result();
    mysql_fetch_row_format(Data,"|");
    printf("Data lenght: %d",strlen(Data));
    key = strtuk( Data, idx, '|' );
    for(new s = -1; s < 175; s++ )// change 175 to your value count
    {
        switch(s)
        {
            case 0: strmid(Pinfo[playerid][Password], key, 0, strlen(key), 255);
            case 1: Pinfo[playerid][Level] = strval( key );
            case 2: Pinfo[playerid][Admin] = strval( key );
            case 3: Pinfo[playerid][Skin] = strval( key );
            case 4: Pinfo[playerid][Cash] = strval( key );
            case 5: Pinfo[playerid][Local] = strval( key );
        }
        key = strtuk( Data, idx, '|' );
    }
    mysql_free_result();
}
and here is strtuk
pawn Код:
strtuk(const str[], &index, delimiter)
{
    new length = strlen(str);
    while ((index < length) && (str[index] == delimiter))
    {
        index++;
    }

    new offset = index;
    new result[128];
    while ((index < length) && (str[index] != delimiter) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = str[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Just always make sure you keep same order, I mean if you use this, its not recommended to add new values in middle of SQL table, also I started loop with -1, because in my table first value is user name, but why we need to load it.
Reply
#4

You can use the array or enum functionaltiy of sscanf .. Look at my query:

pawn Код:
sscanf(mysqlresultline, "e<p<|>dddddddddddddddddddfdddddddddddddddd{s[13]s[13]}>", PlayerStats[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)