MySQL Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Problem (
/showthread.php?tid=274954)
MySQL Problem -
EviLpRo - 07.08.2011
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
Re: MySQL Problem -
JaTochNietDan - 07.08.2011
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.
Re: MySQL Problem -
EviLpRo - 07.08.2011
this work.
thank's you
Re: MySQL Problem -
Johnson_boy - 07.08.2011
And if you want to be check if the query returns something, you should use mysql_num_rows instead.