This code doesn't work for some reason. "Connecting to configured SQL Database" gets printed but not "Connection established or "Connection failed". Anyone have any idea? For anyone wondering, yes I've got the latest version of both libmysql and mysqloo and yes, I've also got them in the correct folders. This is running server side.
require("mysqloo")
dbtest = mysqloo.connect( "127.0.0.1" , "root" , "" , "censoredforfacepunch" , 3306 )
function DM.FW:ConnectToDatabase()
print("Connecting to configured SQL Database")
dbtest.onConnected = function( db )
print("Connection established")
end
dbtest.onConnectionFailed = function( db, err )
print("Connection failed, error: " .. err)
end
dbtest:connect()
end
concommand.Add("connectdb",function() DM.FW:ConnectToDatabase() end)
Your code looks fine, it looks like it's more likely a problem with the MySQL server itself/your credentials and not your code/mysqloo. Check that the port is correct, the MySQL server is running and can accept connections; maybe you should check your firewall settings.
This has been fixed by itself now but I'm still confused about it. Incorrect mysql login shouldn't affect ".onConnectionFailed", right?
It should call that function but I think it wasn't calling it because it wasn't timing out the connection (which was taking too long)
Got this issue again now. It connects but doesnt callback until i run db:ping(). Incredibly weird and annoying. I dont know what's holding it back.
Sorry, you need to Log In to post a reply to this thread.