MySQL Issue?

I understand the majority of this community dislikes PERP, but I’m having a similar issue to this post. Now that tmysql4 has been retired, I’m using mysqloo v9 with the tmysql wrapper and getting the following error.


[ERROR] gamemodes/rp/gamemode/sv_hooks.lua:77: attempt to index global 'database' (a nil value)
  1. unknown - gamemodes/rp/gamemode/sv_hooks.lua:77

And the offending line of code is just here.


database:Query("SELECT `key`, `value` FROM `rp_system` WHERE `key`='date_year_" .. GAMEMODE.ServerDateIdentifier .. "' OR `key`='date_month_" .. GAMEMODE.ServerDateIdentifier .. "' OR `key`='date_day_" .. GAMEMODE.ServerDateIdentifier .. "'", function ( Whatever )

And this is the function (forgive me if the terminology is wrong, my lua knowledge is extremely limited and assumed)


local database, err = tmysql.initialize(SQL_INFO_1, SQL_INFO_2, SQL_INFO_3, SQL_INFO_4, 3306);
	
	if not database then
		print( err )
		return
	end

There is no global named “database”, only a local. And you shouldn’t even be trying to make a global called that.

I sort of understand what you mean, but I don’t quite know how to go about fixing it. How do I make it work correctly?