• Database not Updating
    6 replies, posted
I have been working on this code for a while. This part I am stuck on and kinda confused. So I see nothing wrong with the query, and when it is sent to the database it returns success, but no tables are affected. This is the code: [CODE]function levelup.database.save( charid, char, ply) local char = string.Replace( char, " ", "-" ) local linked = (charid .. char) print(ply.levelup.experience) print(ply.levelup.level) local qry = lvlDB:query( "UPDATE `exp_players` SET `level` = " .. ply.levelup.level .. ", `experience` = " .. ply.levelup.experience .. " WHERE `id` = '" .. linked .. "'" ) qry.onError = function( q, err, sql ) print( "[SPECIAL] Database Error: " .. err ) qry:abort() end qry.onSuccess = function( q, data ) print( "[SPECIAL] Saved Userdata" ) end qry:start() print( "[SPECIAL] Affected Rows: " .. qry:affectedRows() ) end[/CODE] One thing I know for sure is "ply.levelup.experience" and "ply.levelup.level" are defined differently. That is why those two print lines are there, So I can see what they are before running the query. There is nothing wrong with the query sent from what I can tell. If anyone could spot the problem, help would be much appreciated. Also if you need more context code, just ask. Thanks.
Hey, you probably should output the query after you filled them with vars... execute sth like: [code] print( "UPDATE `exp_players` SET `level` = " .. ply.levelup.level .. ", `experience` = " .. ply.levelup.experience .. " WHERE `id` = '" .. linked .. "'") [/code] and check if query is ok. Regards SeaLife
[QUOTE=SeaLife;51585616]Hey, you probably should output the query after you filled them with vars... execute sth like: [code] print( "UPDATE `exp_players` SET `level` = " .. ply.levelup.level .. ", `experience` = " .. ply.levelup.experience .. " WHERE `id` = '" .. linked .. "'") [/code] and check if query is ok. Regards SeaLife[/QUOTE] Just did and the query once again seems fine :/ It returns [CODE]UPDATE `exp_players` SET `level` = 3, `experience` = 12 WHERE `id` = 'test29'[/CODE] I don't understand what is going on :'I
Can I see your database structure?
NEVERMIND I figured it out XD I switched charid and char in this function. I'm stupid haha
[QUOTE=Defton;51585653]NEVERMIND I figured it out XD I switched charid and char in this function. I'm stupid haha[/QUOTE] Thats why you should check the query and your rowset in database :) Good Luck Regards SeaLife
[QUOTE=SeaLife;51585661]Thats why you should check the query and your rowset in database :) Good Luck Regards SeaLife[/QUOTE] So true haha. Thanks for the help <3
Sorry, you need to Log In to post a reply to this thread.