Post your code. Also add this to make sure it actually doesn't error while trying to connect.
databaseObject.onConnectionFailed = function(self, e) print(e) end
(Check your console).
Post your code. Also add this to make sure it actually doesn't error while trying to connect.
databaseObject.onConnectionFailed = function(self, e) print(e) end
(Check your console).
Oh, I didn't know that you could add that parameter to database objects. Anyways, the error I get is
"Couldn't connect to MySQL server on 'localhost' (10061)"
I'm not sure why this is, since my websites and the gm_tmysql module can connect to the same mysql user fine. The reason I prefer mysqloo is because I need to connect to multiple databases.
This code used to work fine too, until I had to reinstall my MySQL server.
local databases = { smf = mysqloo.connect("localhost", "smf", "paswordhere", "smf", 3306) } for _,v in pairs(databases) do v.onConnectionFailed = function(self, e) print(e) end v:connect() end
Are you allowing external connections to connect to the db? It's not on by default but you may have configured it to be so.
WTF. I changed my localhosts to 127.0.0.1 (the same thing) and it started working. I have no idea why but at least it's fixed. The weirdest part is that everything I tested with, websites and gm_tmysql used localhost fine. I'll see whether I have remote connections enabled, although I don't see how it would affect my situation since the mysql server is local.
Is there any way to return the data in the same function the query is declared in without using wait()? It seems wait() just causes the server to lag.
You are not supposed to use wait. Use the callback function(s) that the query object provides.
I think he wants to return a value from the query in a function
Yeah, I don't see any other way to do it without caching everything, which I can do, but just seems like a waste of time when tmysql can do this fine.
query.onSucess = function(q)
return callback(q:getData())
end
? or what
You can't return in the onSuccess function because the function is already run by the time the query is completed.
After using this plugin I get
error loading module 'mysqloo' from file 'c:\testserver\orangebox\garrysmod\lua\
includes\modules\gmsv_mysqloo.dll':
system error 14001
That's literally all I know, I did what the instructions said also
Make sure you have http://www.microsoft.com/en-us/downl....aspx?id=26368 installed. If you run x64 you should probably download the x86 too.
Does this work on GM13 or does it need to be recompiled with the GM13 headers.
Works fine.
I tried to query something with the databaseobject:escape() but it failed, not sure if I was supposed to do it that way but here its my code:
PlayerSaveInit = MySQL:query( "INSERT INTO players (`plyid`)VALUES ( " .. MySQL:escape(ply:SteamID()) .. " )" ) PlayerSaveInit.onSuccess = function() print("Inserted Data") end PlayerSaveInit:start()
but it doesn't works, its like it wasn't called at all...
is it possible that's erroring?
INSERT INTO players (plyid)VALUES ( `" .. MySQL:escape(ply:SteamID()) .. "` )"
do you even need to escape a SteamID
Yeah, no way to mysql inject with a steamid.
You're missing the quotes after VALUES ( and before the )
so should be
MySQL:query( "INSERT INTO players (`plyid`) VALUES ('" .. MySQL:escape( ply:SteamID() ) .. "')" )
I keep getting "MySQL server has gone away" error, is there any way to fix this or do i need to reconnect always when running new query?
That is an issue with your MySQL configuration; increase the value of the wait_timeout system variable. Alternatively, you can send a query every x seconds to keep the connection open (may not work when nobody is connected). When the server closes the connection, you will need to reopen it.
timer.Create( "AntiTimeout", 30, 0, function() local Query = mysql:query( "SHOW STATUS LIKE 'uptime';" ) Query:start() end )
Doesn't run if nobody is connected / has connected to the server. If your server is empty for a while after mapchange and the value of wait_timeout is set to something low (like an hour), the connection will still be closed.
Runs fine. I believe the old "Timers don't run when no one is connected" was changed a while ago.
Ok thanks for the answers!
Ah, thanks for the heads up. Disregard what I said earlier then.
You're welcome.
So i recently found out that you can do
local query = MyDB:query("SELECT 1+1") query:start() query:wait() local data = query:getData()
Essentially the wait function puts the thread on hold until the query has been completed.
Why exactly would you want to put the thread on hold, is it to prevent multiple queries running at once?
You only put that thread that runs that specific code on hold. It completes the query then it runs the code past the wait()
It's so you dont have to use callbacks to send data.
Oh that makes sense. Is that on purpose or just something accidental?
Not sure... Possibly.
?
function _R.Player:SteamID() return "'; DROP TABLE players;" end
But that wouldn't work since the MySQL stuff is ran server-side. You'll need to override it serverside, which you can't.
Try and override the function on serverside.
My FTP client wont accept .dll and I've attempted adding the .dlls through the server CP but it wouldn't work. Do you guys know how I could possibly fix this so I can successfully get my .dlls into the server files like it's needed?
What FTP client are you using?
What is the message the comes up when you try and upload a dll?
You need to talk to your server host and ask them to install the module.
Yeah, I had figured that out afterwards. The host and I are taking care of it, thanks!