Jump to content

[HELP] dbQuery error


steadyfi

Recommended Posts

Hello ! :)

I've got a little problem here with dbQuery. I can't seem to understand how to pass the results correctly to the callbackFunction.

Code:

dbQuery(function(deaths, matches) 
    dbExec(db, "UPDATE main SET deaths=?, matches=? WHERE account=?", tonumber(deaths) + 1, tonumber(matches) + 1, getAccountName(getPlayerAccount(source))) 
end, {deaths, matches}, db, "SELECT deaths,matches FROM main WHERE account=? LIMIT 1", getAccountName(getPlayerAccount(source))) 

SQL Table:

k4pfM83.png

I have everything set. There you can also see ROW Properties.

Error:

[2015-04-10 14:40:50] ERROR: ***\main_s.lua:92: attempt to perform arithmetic on a nil value 

Thanks ! ;)

Link to comment
dbQuery (  
    function ( q, player ) 
        local p = dbPoll ( q, 0 ); 
        if ( p ) then 
            dbExec ( db, "UPDATE `main` SET `deaths`=?, `matches`=? WHERE `account`=?", tonumber ( p[1]["deaths"] ) + 1, tonumber ( p[1]["matches"] ) + 1, getAccountName ( getPlayerAccount ( player ) ) ); 
        end 
    end, 
{source}, db, "SELECT `deaths`,`matches` FROM `main` WHERE `account`=? LIMIT 1", getAccountName ( getPlayerAccount ( source ) ) ); 

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