Error:
[code]
Timer Error: *******\gamemode\mysql_data.lua:25: attempt to index global 'mysql' (a nil value)
[/code]
Line 25:
[php]
iScript.connect,ok,err = mysql.connect(Host, User, Password, Database)[/php]
Code:
[php]
Host = "*******";
User = "******";
Password = "********";
Database = "*****";
require("mysql");
function iScript.MySQLConnect()
local ok, err
iScript.connect,ok,err = mysql.connect(Host, User, Password, Database)
if( iScript.connect == 0 ) then
print("MySQL Connection Failure.");
print( tostring(err) );
else
print("-MySQL-");
print("--Connected--");
print("---Successfully---");
end
end
function iScript.MySQLConnectionCheck()
local check = mysql.query(iScript.connect,"SELECT * FROM sMoss_members");
if( not check or #check < 1 ) then
mysql.disconnect(iScript.connect)
iScript.connect = mysql.connect(Host, User, Password, Database)
else
print("MySQL Alive.");
end
end
timer.Create("ConnectionTimer", 60, 0, iScript.MySQLConnectionCheck)
function iScript.UserExists(p)
local s = p:SteamID()
local t,i,er = mysql.query(iScript.connect,"SELECT value FROM sMoss_themes WHERE value = '"..s.."'");
if( #t>=1 ) then
return true;
end
end
-- Probably don't need this. But just incase.
function iScript.GetMemberID(p)
local s = p:SteamID()
local t,i,er = mysql.query(iScript.connect, "SELECT id_member FROM sMoss_themes WHERE value = '"..s.."'");
for k,v in pairs(t) do
return v[1]
end
[/php]
I usually got that when the mysql dll was corrupt.
Do you have the mysql module loaded?
Since you're requiring it, it might be that there's an error loading it. Check your console (and make sure you have libmysql.dll siting next to srcds.exe)
[QUOTE=AzuiSleet;19709321]Check your console (and make sure you have libmysql.dll siting next to srcds.exe)[/QUOTE]
This, more likely than not. I completely forgot that when installing another server (Was lazy and just copied across the module) and spent quite a few minutes trying to figure out what was wrong.
[QUOTE=antid2;19698440]Error:
[code]
Timer Error: *******\gamemode\mysql_data.lua:25: attempt to index global 'mysql' (a nil value)
[/code]
Line 25:
[php]
iScript.connect,ok,err = mysql.connect(Host, User, Password, Database)[/php]
Code:
[php]
Host = "*******";
User = "******";
Password = "********";
Database = "*****";
require("mysql");
function iScript.MySQLConnect()
local ok, err
iScript.connect,ok,err = mysql.connect(Host, User, Password, Database)
if( iScript.connect == 0 ) then
print("MySQL Connection Failure.");
print( tostring(err) );
else
print("-MySQL-");
print("--Connected--");
print("---Successfully---");
end
end
function iScript.MySQLConnectionCheck()
local check = mysql.query(iScript.connect,"SELECT * FROM sMoss_members");
if( not check or #check < 1 ) then
mysql.disconnect(iScript.connect)
iScript.connect = mysql.connect(Host, User, Password, Database)
else
print("MySQL Alive.");
end
end
timer.Create("ConnectionTimer", 60, 0, iScript.MySQLConnectionCheck)
function iScript.UserExists(p)
local s = p:SteamID()
local t,i,er = mysql.query(iScript.connect,"SELECT value FROM sMoss_themes WHERE value = '"..s.."'");
if( #t>=1 ) then
return true;
end
end
-- Probably don't need this. But just incase.
function iScript.GetMemberID(p)
local s = p:SteamID()
local t,i,er = mysql.query(iScript.connect, "SELECT id_member FROM sMoss_themes WHERE value = '"..s.."'");
for k,v in pairs(t) do
return v[1]
end
[/php][/QUOTE]
Make sure you have the MySQL dll installed, also i coded that peace to work with an SMF database in which we were running when i was coding for SpringMoss, i had fucked around with the core of SMF but that all got lost so you may need to change bits and peaces.
yeah i've never messed with mysql for lua, i do php/mysql but not with lua so i have no idea where to begin :) and i have the dll in there, still getting same error, may disable it and make one from scratch
It already comes with a flatfile saving system which works fine, that MySQL in unfinished so it was never fully implemented.
you can just delete mysql_data.lua and remove include("mysql_data.lua") from init.lua.
That's if you want to do it from scratch.
Sorry, you need to Log In to post a reply to this thread.