Why isent this simple mysqloo code working ?

Hi, im working on an addon that integreates mysql and im having trouble with this snip of code:


hook.Add( "PlayerSpawn", "Spawn_Notification", function( ply )
	require("mysqloo")
	ply:ConCommand("say HEI")
	
	local db = mysqloo.connect("84.16.197.166", "phpuser", "phpuserpassword", "gAutoDonationSystems", 3306)
	ply:ConCommand("say HEI2")
	function db:onConnected()
		ply:ConCommand("say Database has connected!")
	end
	ply:ConCommand("say HEI3")
	function db:onConnectionFailed(err)
		ply:ConCommand("say Connection Failed!")
	end
	ply:ConCommand("say HEI4")
end )

What am i doing wrong(the say HEI1…4 is for debugging) ?

My mysqloo files area t garrysmod/lua/bin

Because you’re not running db:connect() to start the connection. Also, you don’t need to and shouldn’t put stuff like that in a hook. It’ll be run when the file is executed. And please for your own sake remove the connection info from your post

[lua]require( “mysqloo” )

local db = mysqloo.connect( “host”, “user”, “password”, “database”, 1234 )

function db:onConnected()

print( "connected" )

end

function db:onConnectionFailed( err )

print( err )

end

db:connect()[/lua]

Ive tried your alternative, i also commented out the bind-address line in my.cnf but nothing worked

Now i get the 111 error code.

Anyone got any suggestions ?

i can literally connect to your database right now. remove your info for your own sake

awaiting ‘drop database gAutoDonationSystems’

well you can only acess the info, witch is just testing info so you cant really do any harm