MySQL Problem
#1

hello

have me small problem in this stock:

pawn Код:
stock GetPlayerKills(playerid)
{
    new Kills,szResult[128];
    format(szResult,128,"SELECT `Kills` FROM `Users` WHERE `Nick`='%s'",GetName(playerid));
    mysql_query(szResult);
    mysql_store_result();
    if(mysql_retrieve_row()) Kills = mysql_fetch_int();
    mysql_free_result();
    return Kills;
}
this always return -1...
what's the problem ?

thank's for the helpers
Reply
#2

pawn Код:
stock GetPlayerKills(playerid)
{
    new Kills,szResult[128];
    format(szResult,128,"SELECT `Kills` FROM `Users` WHERE `Nick`='%s'",GetName(playerid));
    mysql_query(szResult);
    mysql_store_result();
    Kills = mysql_fetch_int();
    mysql_free_result();
    return Kills;
}
Have you tried taking out the retrieve row part like I showed in my above example? That may already be retrieving a result and moving it onto the next one, when there isn't any.
Reply
#3

this work.
thank's you
Reply
#4

And if you want to be check if the query returns something, you should use mysql_num_rows instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)