Jump to content

Error on mysql saving.


Recommended Posts

Hey all :( sorry for beeing selfish on last post..

I have a problem saving player data, when he quit, this suposes to update their data on mysql table.

But this updates, all the table values, why?? or how to set just update player row?

function server.logout( thePlayer ) 
    if ( thePlayer ~= "" ) then 
        if ( getElementData( thePlayer, "Connection" ) == 1 ) then 
            local save = dbQuery(databaseINFO.connection, "UPDATE ffw_users SET IngameName= ?" , getPlayerName( thePlayer ) ) -- Current InGame Name 
            dbFree( save ) 
        end 
    end 
end 
  
addEventHandler("onPlayerQuit", getRootElement(), 
    function()  
        server.logout( source ) 
    end 
) 
  

Link to comment

Because you aren't specifying to who to set the data to, you need to specifiy it with his account name or whatever you are using, like this:

dbExec ( databaseINFO.connection, "UPDATE ffw_users SET IngameName = ? WHERE AccountName = ?", getPlayerName ( thePlayer ), getAccountName ( getPlayerAccount ( thePlayer ) ) ) 

Also, use dbExec instead of dbQuery, since you don't need to get any data from it, just to know if it updated or not ( true/false ).

Link to comment
Hey all :( sorry for beeing selfish on last post..

I have a problem saving player data, when he quit, this suposes to update their data on mysql table.

But this updates, all the table values, why?? or how to set just update player row?

function server.logout( thePlayer ) 
    if ( thePlayer ~= "" ) then 
        if ( getElementData( thePlayer, "Connection" ) == 1 ) then 
            local save = dbQuery(databaseINFO.connection, "UPDATE ffw_users SET IngameName= ?" , getPlayerName( thePlayer ) ) -- Current InGame Name 
            dbFree( save ) 
        end 
    end 
end 
  
addEventHandler("onPlayerQuit", getRootElement(), 
    function()  
        server.logout( source ) 
    end 
) 
  

In case of deleting :D

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