• MySQL connection problem
    6 replies, posted
Hello, I have some trouble with connection to mysql database using gm_mysqloo since I reinstall my os to windows 8, before reinstall all works fine. I put libmySQL.dll to orgnagebox folder and gmsv_mysqloo.dll to the orangebox\garrysmod\lua\includes\modules\. Is there any solution? Code I use: [CODE]require("mysqloo") local DATABASE_HOST = "www.ownweb.ru" local DATABASE_PORT = 3306 local DATABASE_NAME = "db_name" local DATABASE_USERNAME = "login" local DATABASE_PASSWORD = "pass" function afterConnected(database) print(1) end function connectToDatabase() local databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT) databaseObject.onConnected = afterConnected databaseObject.onConnectionFailed = function(msg) print("error") print(msg) end databaseObject:connect() print(2) end connectToDatabase()[/CODE]
Since it stopped working after you reinstalled but with same script, there's probably some error with the modules. If there's errors with the modules, theres most likely some error in your console. Give us your console history after you've run the script. Do you use Gmod13?
No, I use Gmod 12. Here is the log: [QUOTE] lua_openscript test.lua Running script test.lua... 2 error [Database: 184977A8] [/QUOTE] Also login/pass/db name is correct because I use them to connect via phpMyAdmin.
[lua]databaseObject.onConnectionFailed = function(db, msg) print("error") print(msg) end[/lua] Do that and then run it, it should give you the proper error.
Now I get this error [QUOTE]lua_openscript test.lua Running script test.lua... 2 error Can't connect to MySQL server on 'www.ownweb.ru' (10060)[/QUOTE]
your database object can't be local or else the connection will disappear when the variable is garbage collected also, that error means the hostname is wrong
I change host name from domain name to ip and make db object global, now all works fine. Thanks to banana lord and Drakehawke.
Sorry, you need to Log In to post a reply to this thread.