Help with MySQL
I have file mysql.lua. Code: require ("mysqloo") // Include the modules
local DATABASE_HOST = "92.53.96.***" // database host (can be an ip) local DATABASE_PORT = 3306 // port to the database, you probably wont need to change this unless you get told to local DATABASE_NAME = "****2_server" // name of the database local DATABASE_USERNAME = "****2_server" // username which you use to access it local DATABASE_PASSWORD = "**************Cxg796sk" // password of the username
function connectToDatabase() databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT) databaseObject.onConnected = function() print("Database linked!") end databaseObject.onConnectionFailed = function() print("Failed to connect to the database.") end databaseObject:connect() end
connectToDatabase()
But if I try to run it from console (lua_openscript mysql.lua) I have error. [ERROR] lua/mysql.lua:1: Couldn't load module library!
- require - [C]:-1
- unknown - lua/mysql.lua:1
Can anyone help?
Is that your MYSQL details?
Edit: I'm stupid, he blurred some of his details out
Byjakoblarsenesbjergat 21st of April 2018 15:48:28
Is that your MYSQL details?Edit:I'm stupid, he blurred some of his details out
Even if it were real data. There's an empty table)
Well you do have the mysql module installed right?
I drop gmcl_mysqloo.dll and gmsv_mysqloo.dll in garrysmod\lua\includes\modules And gmsv_bromsock_linux.dll gmsv_bromsock_win32.dll gmsv_mysqloo_linux.dll gmsv_mysqloo_win32.dll gmsv_tmysql4_linux.dll gmsv_tmysql4_win32.dll in /garrysmod/lua/bin Everything seems to be
I'd really only install the one for your OS (either linux or win32, not both)
ByMomoxat 21st of April 2018 16:23:48
I'd really only install the one for your OS (either linux or win32, not both)
Connection to MySQL via DarkRP works.
Edited Nobody can help?
Edited The problem was solved. Thanks NaNpx. Working code - https://github.com/FredyH/MySQLOO/blob/master/Examples/database.lua