SA-MP Forums Archive
SQL Lite ( Loading from database always returns 0 ) - 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)
+--- Thread: SQL Lite ( Loading from database always returns 0 ) (/showthread.php?tid=371548)



SQL Lite ( Loading from database always returns 0 ) - [WSF]ThA_Devil - 23.08.2012

pawn Код:
GetPlayerLevel(playerid)
{
    new Query[ 200 ],Field[ 20 ];
    format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s'", DB_Escape(Gn(playerid)));
    printf(Query);
    new DBResult:Result = db_query(Database,Query);
    db_get_field_assoc(Result, "LEVEL", Field, 30);
    printf("%i",strval(Field));
    return strval(Field);
}
Query is correct and tested, level is at default 1, it's 1 in database too, but i don't know reason why it returns me 0 all the time. No matter which level player is.


Re: SQL Lite ( Loading from database always returns 0 ) - ReneG - 23.08.2012

You're trying to fetch a field that you haven't specified.

PHP код:
SELECT `LEVELFROM `USERSWHERE `NAME` = '%s'