Database not Updating

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:


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

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:



print( "UPDATE `exp_players` SET `level` = " .. ply.levelup.level .. ", `experience` = " .. ply.levelup.experience .. " WHERE `id` = '" .. linked .. "'")


and check if query is ok.

Regards
SeaLife

Just did and the query once again seems fine :confused:
It returns


UPDATE `exp_players` SET `level` = 3, `experience` = 12 WHERE `id` = 'test29'

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

Thats why you should check the query and your rowset in database :slight_smile:

Good Luck

Regards
SeaLife

So true haha. Thanks for the help <3