Why the output returns -1 ?
#1

pawn Код:
stock mysql_Int(db[],fl[],output,input[])
{
    new query[256],Result[256];
    format(query,sizeof(query),"SELECT %s FROM %s WHERE %s",fl,db,input);
    samp_mysql_query(query);
    samp_mysql_store_result();
    if(samp_mysql_fetch_row(Result)==1)
    {
      samp_mysql_fetch_row(Result);
        output=strval(Result);
        return output;
    }
    return 0;
}
if i do this: mysql_Int("users","id",playerinfo[playerid][uid],string); (string = `name`='%s') and then i print playerinfo[playerid][uid] then i see -1
But if i do this: printf("%d",mysql_Int("users","id",playerinfo[playerid][uid],string)) then i get the Real ID

How to fix it?
Reply
#2

pawn Код:
stock mysql_Int(db[],fl[],input[])
{
    new query[256],Result[256],value[11]; //value is an integer so it doesnt have to be a large string.
    format(query,sizeof(query),"SELECT %s FROM %s WHERE %s",fl,db,input);
    samp_mysql_query(query);
    samp_mysql_store_result();
    if(samp_mysql_fetch_row(Result)==1)
    {
        samp_mysql_strtok(value,"|",Result);
        new output=strval(value);
        return output;
    }
    return 0;
}
Remove the output from the function line, no need for it. Tokenize it, grab the integer, return it. So it can return 100, 5, 26, or 1. Any integer up to 11 digits long. so 10000000000 is an 11 length integer. Now this should work. Now use:
pawn Код:
playerinfo[playerid][uid] = mysql_Int("users","id",string);
Reply
#3

I need to fix a script with this Bug !
and that script is 43560 lines with 200+ Mysql_Int
Reply
#4

why doesnt my code work...
Reply
#5

Quote:
Originally Posted by R4nk3d
why doesnt my code work...
Because i want my code fixed not a other code
Reply
#6

Quote:
Originally Posted by Gijsmin (Spot-Host.co.uk)
Quote:
Originally Posted by R4nk3d
why doesnt my code work...
Because i want my code fixed not a other code
this is the fixed code.... ur code didnt make sense and this is the revised code that will work.
Reply
#7

TOPIC SOLVED

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)