1. Post #601
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    Recently, I experienced some problems on my MySQL server and I had to reinstall. After reinstalling and restoring backups, I recreated the user accounts I had previously, so my SMF and Wordpress sites worked. Now however, my MySQLoo scripts no longer work. Specifically, running mysqloo:connect("blah"):query("SELECT blah") is returning nil. I have double checked several times about whether my login credentials are right. Additionally, I have checked my mysql server logs and gmod server logs and found nothing. There appears to be no errors when running mysqloo:connect either.

    If my credentials are wrong, would mysqloo:connect:query be expected to return nil? If so then I think some better feedback would be good.

    Anyways, do you guys have any suggestions or possible ideas on how to debug and fix this? Thanks.
    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).
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  2. Post #602
    infinitywrai's Avatar
    December 2007
    539 Posts
    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
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #603
    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.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  4. Post #604
    infinitywrai's Avatar
    December 2007
    539 Posts
    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.
    Reply With Quote Edit / Delete Windows Vista United States Show Events Dumb Dumb x 2 (list)

  5. Post #605
    Nexus435's Avatar
    July 2010
    1,461 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  6. Post #606
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  7. Post #607
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    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
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  8. Post #608
    Nexus435's Avatar
    July 2010
    1,461 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #609
    metromod.net
    _Chewgum's Avatar
    April 2010
    2,216 Posts
    query.onSucess = function(q)
    return callback(q:getData())
    end

    ? or what
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #610
    Nexus435's Avatar
    July 2010
    1,461 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #611
    Title

    August 2009
    301 Posts
    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
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  12. Post #612
    metromod.net
    _Chewgum's Avatar
    April 2010
    2,216 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  13. Post #613
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    Does this work on GM13 or does it need to be recompiled with the GM13 headers.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Zing Zing x 1 (list)

  14. Post #614
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    Works fine.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Winner Winner x 1 (list)

  15. Post #615

    February 2010
    129 Posts
    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...
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events

  16. Post #616
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    is it possible that's erroring?
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  17. Post #617
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    INSERT INTO players (plyid)VALUES ( `" .. MySQL:escape(ply:SteamID()) .. "` )"
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  18. Post #618
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    do you even need to escape a SteamID
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  19. Post #619
    Nexus435's Avatar
    July 2010
    1,461 Posts
    do you even need to escape a SteamID
    Yeah, no way to mysql inject with a steamid.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #620
    Ruzza's Avatar
    December 2011
    1,137 Posts
    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...
    You're missing the quotes after VALUES ( and before the )

    so should be

    MySQL:query( "INSERT INTO players (`plyid`) VALUES ('" .. MySQL:escape( ply:SteamID() ) .. "')" )
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  21. Post #621
    LITTLE PREB FAGGOT
    ollie's Avatar
    January 2012
    902 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  22. Post #622
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  23. Post #623
    Ruzza's Avatar
    December 2011
    1,137 Posts
    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?
    timer.Create( "AntiTimeout", 30, 0, function()
    	local Query = mysql:query( "SHOW STATUS LIKE 'uptime';" )
    	Query:start()
    end )
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  24. Post #624
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Disagree Disagree x 1 (list)

  25. Post #625
    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.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 1Agree Agree x 1 (list)

  26. Post #626
    LITTLE PREB FAGGOT
    ollie's Avatar
    January 2012
    902 Posts
    Ok thanks for the answers!
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  27. Post #627
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    Runs fine. I believe the old "Timers don't run when no one is connected" was changed a while ago.
    Ah, thanks for the heads up. Disregard what I said earlier then.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  28. Post #628
    Ruzza's Avatar
    December 2011
    1,137 Posts
    Ah, thanks for the heads up. Disregard what I said earlier then.
    You're welcome.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events Friendly Friendly x 1 (list)

  29. Post #629
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1Informative Informative x 1 (list)

  30. Post #630
    Ruzza's Avatar
    December 2011
    1,137 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  31. Post #631
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1Disagree Disagree x 1 (list)

  32. Post #632
    Ruzza's Avatar
    December 2011
    1,137 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  33. Post #633
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    Oh that makes sense. Is that on purpose or just something accidental?
    Not sure... Possibly.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  34. Post #634
    Gold Member
    marvincmarvin's Avatar
    January 2011
    796 Posts
    Yeah, no way to mysql inject with a steamid.
    ?
    function _R.Player:SteamID()
         return "'; DROP TABLE players;"
    end
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 2 (list)

  35. Post #635
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,558 Posts
    But that wouldn't work since the MySQL stuff is ran server-side. You'll need to override it serverside, which you can't.
    Reply With Quote Edit / Delete United States Show Events

  36. Post #636
    Ruzza's Avatar
    December 2011
    1,137 Posts
    ?
    function _R.Player:SteamID()
         return "'; DROP TABLE players;"
    end
    
    Try and override the function on serverside.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  37. Post #637

    January 2012
    19 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  38. Post #638
    Gold Member
    PaellaPablo's Avatar
    May 2011
    227 Posts
    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?
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  39. Post #639
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    You need to talk to your server host and ask them to install the module.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  40. Post #640

    January 2012
    19 Posts
    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!
    Reply With Quote Edit / Delete Windows 7 United States Show Events