Jump to content

MySQL - getting column data


Recommended Posts

Hi guys, im trying to get the "password" column, where the player's account is. Here is what i got, but i got stuck.

function getAccountPassword ( player, command, account )  
    if ( account ) and ( type ( account ) == "string" ) then 
        if ( doesAccountExist ( account ) == true ) then 
            local new = dbQuery ( dbc, "SELECT * FROM Accounts WHERE name=?", accnt ) 
            local result,n_rows = dbPoll ( new, - 1 ) 
            -- Not to sure what to do... -- 
            outputChatBox ( tostring ( n_rows ) ) 
        end 
    end 
end 
addCommandHandler ( "ga", getAccountPassword ) 

Link to comment

I tried that, but now its saying "unknown index," so i made this code:

-- Get accounts password -- 
function getAccountPassword ( player, command, account )  
    if ( account ) and ( type ( account ) == "string" ) then 
        if ( doesAccountExist ( account ) == true ) then 
            local new = dbQuery ( dbc, "SELECT * FROM Accounts WHERE name=?", accnt ) 
            local result,n_rows = dbPoll ( new, - 1 ) 
            -- Not to sure what to do... -- 
            local password = result[2] 
            outputChatBox ( tostring ( password ) ) 
        end 
    end 
end 
addCommandHandler ( "ga", getAccountPassword ) 

and its returning nil.

Link to comment
I said result [ 1 ], not result [ 2 ], as it only found one row for sure.

Still is returning nil...

Here is the code:

-- Get accounts password -- 
function getAccountPassword ( player, command, account )  
    if ( account ) and ( type ( account ) == "string" ) then 
        if ( doesAccountExist ( account ) == true ) then 
            local new = dbQuery ( dbc, "SELECT * FROM Accounts WHERE name=?", accnt ) 
            local result = dbPoll ( new, - 1 ) 
            -- Not to sure what to do... -- 
            local password = result[1] 
            outputChatBox ( tostring ( password ) ) 
        end 
    end 
end 
addCommandHandler ( "ga", getAccountPassword ) 

Edited by Guest
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...