Mysql problem.

ok im trying to make a function that get the kills and the deaths from a mysql db but when im trying to get the value it dosnt work.
Ive tried the sql code in phpmyadmin and it works there but not ingame, i a strange value… i just the same way to get values on anouther function.
i only get one error but that is tonumber() couse the value i get from the db is nil.
when i use print to see the value i get this: “table: 030B3B98”

function KD(ply, text)
    local Array = string.Explode( " ", text );
        
        if Array[1] == "/kd" then
                local db, error = mysql.connect("**********", "**********", "**********", "**********")  
                if (db == 0) then print(tostring(error) .. "
") return end  
                sel, isok, error = mysql.query(db, "SELECT Kills FROM users WHERE SteamID = '".. ply:SteamID().."'");
                if (!isok) then
                    print(tostring(error) .. "
");
                end
                local succ, error = mysql.disconnect(db)
                if (not succ) then
                print( error );
                end
                print(sel[1])
                Kills = tonumber(sel[1])
                
                local db, error = mysql.connect("**********", "**********", "**********", "**********")  
                if (db == 0) then print(tostring(error) .. "
") return end  
                sel2, isok, error = mysql.query(db, "SELECT Deaths FROM users WHERE SteamID = '".. ply:SteamID().."'");
                if (!isok) then
                    print(tostring(error) .. "
");
                end
                local succ, error = mysql.disconnect(db)
                if (not succ) then
                print( error );
                end
                print(sel2[1])
                Deaths = tonumber(sel2[1])
                KD = Kills/Deaths
                ply:PrintMessage( HUD_PRINTTALK, "Your K/D is: ".. KD);            
            return false
        end
end
hook.Add( "PlayerSay", "KD", KD)

Help!

Try to use PrintTable() with your value instead of just print, maybe the result will help you understand what your code is giving you.

Try this, I have not tested since I don’t really wanna setup tables in mysql but please reply if it does not work and I will test and ensure it works.

[lua]
function KD( ply, text )
local Array = string.Explode( " ", text )
if Array[1] == “/kd” then
local db, error = mysql.connect( “", "”, “", "” )
if ( db == 0 ) then print( tostring( error ) … "
" ) return end

    local Kills = mysql.query( db, "SELECT Kills FROM users WHERE SteamID = '" .. ply:SteamID().. "'" )
	local Deaths = mysql.query( db, "SELECT Deaths FROM users WHERE SteamID = '" .. ply:SteamID().. "'" )
			
	Ratio = ( tostring( Kills[1][1] ) .. ":" .. tostring( Deaths[1][1] ) )

    ply:PrintMessage( HUD_PRINTTALK, "Your K/D is: ".. Ratio )            
    return false  
end  

end
hook.Add( “PlayerSay”, “KD”, KD)
[/lua]

thanks it workeddarklighte