• mysqloo problem
    21 replies, posted
This is my code: [lua] require("mysqloo") local DATABASE_HOST = "localhost" local DATABASE_PORT = 3306 local DATABASE_NAME = "Players" local DATABASE_USERNAME = "root" local DATABASE_PASSWORD = "password" DBTable = "Flood" 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() [/lua] I have tried it in init.lua (The initial way I was doing it was in here). I've also tried doing in the autorun folder (server folder) and I always get this error: 17:26:10 L 02/12/2012 - 18:26:24: Lua Error: [gamemodes/Flood/gamemode/init.lua:20] attempt to index global 'mysqloo' (a nil value) Basically I'm changing Flood from the original Flood tmysql to mysqloo (So it works on linux).
Failed suggestion.
[QUOTE=wizardsbane;34666379]Remove the parenthesis. Syntax for require statements as defined by the PIL is [lua]require "package"[/lua] [editline]12th February 2012[/editline] Don't know if that's the entire problem, but since you've grabbed this from the tutorial, I'm thinking it's just some Lua anachronism.[/QUOTE] Didn't work, I'm pretty sure () work either way.
[QUOTE=Mrkrabz;34666466]Didn't work, I'm pretty sure () work either way.[/QUOTE] Yeah, it was mostly just a prod at something that seemed odd. I mean, this code should work if the person who posted the original tutorial had tested the code. I'll look into it more, or someone else will see the problem before me. [editline]12th February 2012[/editline] Which line counts as line 20 in that snippet? The require statement or the mysqloo.connect part?
[QUOTE=wizardsbane;34666490]Yeah, it was mostly just a prod at something that seemed odd. I mean, this code should work if the person who posted the original tutorial had tested the code. I'll look into it more, or someone else will see the problem before me.[/QUOTE] Thanks, I used this a while ago and it worked fine, this is my full code It's pretty long so I put it on pastebin. [url]http://pastebin.com/pqHqCpFa[/url]
What's killing me is that your syntax is fine according to mysqloo's creator ([url]http://www.facepunch.com/threads/933647-Gm_MySql-v1.0-OO-edition[/url]), it's just that mysqloo is found to be a nil object, like it isn't being defined when you require it. [editline]12th February 2012[/editline] Possibly helpful? [url]http://www.facepunch.com/threads/994126[/url]
[QUOTE=wizardsbane;34666690]What's killing me is that your syntax is fine according to mysqloo's creator ([url]http://www.facepunch.com/threads/933647-Gm_MySql-v1.0-OO-edition[/url]), it's just that mysqloo is found to be a nil object, like it isn't being defined when you require it. [editline]12th February 2012[/editline] Possibly helpful? [url]http://www.facepunch.com/threads/994126[/url][/QUOTE] I had a look at that but his problem was that he had it inside the spawn function I believe
One last try: are you running this on a Linux machine? If you are, did you make sure to try what I think was Chrisaster's previous fix of renaming the original .dll to gmsv_mysqloo_linux.dll? [url]http://www.facepunch.com/threads/933647?p=32571520&viewfull=1#post32571520[/url]
I'm using the linux binarys that were released, do they need to be renamed?
What's their names now?
gmcl_mysqloo_i486.dll gmsv_mysqloo_i486.dll
Uh. Try without the _486? gmsv_mysqloo.dll ?
[QUOTE=Freze;34667736]Uh. Try without the _486? gmsv_mysqloo.dll ?[/QUOTE] 19:53:59 L 02/12/2012 - 20:54:13: Lua Error: [gamemodes/Flood/gamemode/init.lua:20] attempt to index global 'mysqloo' (a nil value) 19:53:59 L 02/12/2012 - 20:54:13: Load Gamemode: 'Flood' 19:53:59 L 02/12/2012 - 20:54:13: Lua Error: [cpp]
Stupid question, but: You sure they're the right place? The .dll files?
[QUOTE=Freze;34667941]Stupid question, but: You sure they're the right place? The .dll files?[/QUOTE] I'm pretty sure, if I rename it to something random it errors. They are in [B]/orangebox/garrysmod/lua/includes/modules[/B]
Remove "i486" and use "linux". I think that's what the fix implies.
error loading module 'mysqloo' from file '/home/gmod/srcds/orangebox/garrysmod/lua/includes/modules/gmsv_mysqloo_linux.dll': libmysql.so.16: cannot open shared object file: No such file or directory WireMod Installed. Version: 2521
Tried redownloading them?
[QUOTE=Freze;34668589]Tried redownloading them?[/QUOTE] Yep
I am having the same problem with Linux MYSQLOO... [editline]13th February 2012[/editline] error loading module 'mysqloo' from file '/home/gmod/navalwarfare/orangebox/garrysmod/lua/includes/modules/gmsv_mysqloo_linux.dll': libmysql.so.16: cannot open shared object file: No such file or directory Try gmsv_mysqloo_linux...
Place libmysql.so.16 in orangebox/bin. EDIT: You can get those binarys from here [url]http://dev.mysql.com/downloads/connector/c/#downloads[/url]
[QUOTE=Matt W;34676676]Place libmysql.so.16 in orangebox/bin. EDIT: You can get those binarys from here [url]http://dev.mysql.com/downloads/connector/c/#downloads[/url][/QUOTE] Thank you, that worked! :D Now Just need to make Sourcebans connect to the database...
Sorry, you need to Log In to post a reply to this thread.