Little help - MYSQL.
#6

pawn Код:
GetNameFromSql(accId)
{
    new
        query[STR_MAX],
        strid[32]
    ;
    format(query, sizeof(query), "SELECT Name FROM players WHERE accid = '%d' LIMIT 1", accId);
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows()==0)
    {
        format(strid, sizeof(strid), "None");
        return strid;
    }
    else
    {
                new name[3][128];
        mysql_fetch_row(strid);
        mysql_free_result();
                split(strid, name, '_');
                format(strid, sizeof(strid), "%s %s", name[0], name[1]);
        return strid;
    }
}
try this....

and if you don't have split function here it is,

pawn Код:
stock split(const strsrc[], strdest[][], delimiter)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
Reply


Messages In This Thread
Little help - MYSQL. - by NewbBeginner - 03.07.2011, 14:25
Re: Little help - MYSQL. - by =WoR=Varth - 04.07.2011, 00:14
Re: Little help - MYSQL. - by NewbBeginner - 05.07.2011, 17:14
Re: Little help - MYSQL. - by =WoR=Varth - 06.07.2011, 00:06
Re: Little help - MYSQL. - by NewbBeginner - 06.07.2011, 14:11
Re: Little help - MYSQL. - by CoaPsyFactor - 06.07.2011, 14:20

Forum Jump:


Users browsing this thread: 4 Guest(s)