how to store SELECT values from DB in Variable

06/20/2018 22:27 torce#1
hi

i hope to find help here

am facing a problem with retrieving some data from my DB with SELECT query

am doing a Quest that needs to check Pet level before updating its parameters

the new_petsystem table in DB looks like

Code:
 id  | name | level | evolution | exp | expi | bonus0 | bonus1 | bonus2 | skill0 |skill0lv etc
now when i UPDATE parameters it works fine no problem

like this :

Code:
 mysql_direct_query(string.format("UPDATE player.new_petsystem SET level = 82, evolution = 3, exp = 0, expi = 0, bonus0 = 95, bonus1 = 95, bonus2 = 95 WHERE id = %d;", item.get_id()));
but when i try to retrieve pet level and store it in variable
i trid many ways like "

Code:
 local lvlCheck =  mysql_direct_query("SELECT level FROM player.new_petsystem WHERE id =  "..item.get_id().."; ")
then i try to show what was stored in variable like :
Code:
 syschat(" result is : "..lvlCheck.." ")
it doesnt work .. i tried many ways but no luck
some times it shows me nil result . some times it shows me some big number that i dont know where it came from

hope if any one can help me of the right way to retrieve values from DB and store it in a variable to use it in my quest


thanks in advance