Can't insert into MYSQL database?

Hello FP,
I tried to play around with mysql(since I am a bit new to it yet), and got selecting etc from the database working fine, but when I do insert, it prints that it succeed, but phpmyadmin still shows that the table is empty.

the line of the query is:



db:query("INSERT INTO bans VALUES ('s', 'Cookies!');")


the ‘s’ is just an replacement for the steamid etc etc, I looked into other addons(eg QAC) and its the same there, and as I said, the console prints that the function succeed.

using Mysqloo module.

I can’t see anything wrong with the syntax, are you sure you’re connected to the database? Alternatively you could do yourself a favour and use this wrapper library

The function also checks before injecting if the status is set the connected, and mysql also says that I am connected to it, the user also got full permissions to the database, but sometimes the server crashes upon injecting.

Edit:
Incase you want to know everything thats done inside the function to insert heres the content of it:



if db:status() != mysqloo.DATABASE_CONNECTED then
	connect2db()
	print("Database wasn't connected, please redo the command.")
	return
end
--Check if banned
local query = db:query("SELECT * FROM bans WHERE SID = 's';")
function query:onSuccess()
	if #query:getData() >=1 then return end
	if #query:getData() == 0 then
		local query2 = db:query("INSERT INTO bans VALUES ('s', 'Cookies!');")
	end
	print("Inserted into database.")
end
function query:onError(db, err)
	print("Query failed: "..err)
end
query:wait()
query:start()


I JUST noticed I wrote the 2nd query wrong, lemme fix that asap.

[editline]12th September 2015[/editline]

Oh well, now it works >-<

Anyways, sometimes when I run a query, my server crashes(also writes crashdumbs in the windows crash file format), and how can I make that the connection is constantly on? So they dont have to like type 2 times the command, QAC got a 90 second check to reconnect the database(I got that too) but it still has to reconnect manually.

[editline]12th September 2015[/editline]

With QAC I ment globalban >-<

[editline]12th September 2015[/editline]

With crash I mean this:

the readdb concommand is as follow:



concommand.Add("readdb", function(ply)
	local query = db:query("SELECT * FROM bans")
	function query:onSuccess()
		print("Query success.")
		PrintTable(query:getData())
	end
	function query:onError(db, err)
		print("Query failed: "..err)
	end
	query:start()
end)