Jump to content

[HELP] MySQL selecting


Imposter

Recommended Posts

Hi, i need help selecting, i need to grab the row "player_name" but i cant get it working, here is my code.

  
function onPlayerLogin(thePreviousAccount, theCurrentAccount) 
    -- Attempt to load data 
    local theAccountQuery =  dbQuery(theHandler, "SELECT * FROM account_stats WHERE player_name=?;", getAccountName(theCurrentAccount)) 
    local theAccountResult = dbPoll(theAccountQuery, -1) 
    if (theAccountResult) then 
        outputChatBox("FOUND ACCOUNT!", source) 
        outputChatBox(theAccountResult['player_name'], source) -- Doesnt Work 
    else 
        outputChatBox("DATA NOT FOUND!", source) 
    end 
    -- Free Query 
    dbFree(theAccountQuery) 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) 
  

Link to comment
function onPlayerLogin(thePreviousAccount, theCurrentAccount) 
    -- Attempt to load data 
    local theAccountQuery =  dbQuery(theHandler, "SELECT * FROM account_stats WHERE player_name='?'", getAccountName(theCurrentAccount)) 
    local theAccountResult = dbPoll(theAccountQuery, -1) 
    if (theAccountResult) then 
        outputChatBox("FOUND ACCOUNT!", source) 
        outputChatBox(theAccountResult[1]['player_name'], source) -- Doesnt Work 
    else 
        outputChatBox("DATA NOT FOUND!", source) 
    end 
    -- Free Query 
    dbFree(theAccountQuery) 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) 

Should it work, I guess. Not tested yet.

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...