Jump to content

Problem with SQL


kuba90pl

Recommended Posts

Hey!

I have problem with SQL. I cant get results from my DB (I know there is a record (i checkd this with num_rows(=1)))

Here is my db schema:

    dbQuery(db,"CREATE TABLE IF NOT EXISTS avatar(id INT,name TEXT,pass TEXT,food INT,games INT,health INT,energy INT,money INT,time INT)") 

and here is my problem:

function avatarLogin(player,login,pass) 
     
local query = dbQuery(db,"SELECT * FROM `avatar` WHERE `name` = ?",login) 
local result, num_affected_rows, errmsg = dbPoll ( query, -1 ) 
 for i,id in ipairs (result) do 
    for column,val in ipairs (id) do 
        server.log(val[column]) 
    end 
end 
  
end 

but i dont get anything from this ( i just know that num_affected_rows = 1 so there is a record in db but i cant get retrieve it).

Help me please or give me some tip!

Link to comment
function avatarLogin ( player, login, pass ) 
    local query = dbQuery ( db,"SELECT * FROM `avatar` WHERE `name` = ?", login ) 
    local result, num_affected_rows, errmsg = dbPoll ( query, -1 ) 
    for i, id in ipairs ( result ) do 
        for column, val in pairs ( id ) do -- Here, you had to use "pairs" because the table is not indexed. 
            server.log ( val [ column ] ) 
        end 
    end 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...