Attempt to index a nill value (global 'mysql')

hello, i have a problem with my script, attempt to index a nill value (‘global ’ mysql’) please ?

local AccountsIndex, Accounts, SharedAccounts = {}, {}, {}
ESX = nil

TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

MySQL.ready(function()
local result = MySQL.Sync.fetchAll(‘SELECT * FROM addon_account’)

for i=1, #result, 1 do
	local name   = result[i].name
	local label  = result[i].label
	local shared = result[i].shared

	local result2 = MySQL.Sync.fetchAll('SELECT * FROM addon_account_data WHERE account_name = @account_name', {
		['@account_name'] = name

Hi, essentially it cannot find MySQL anywhere in this resource. Ensure that you have the oxmysql resource installed. If you are using another SQL resource it would be similar.
Secondly ensure that you are importing it into the resource where this script is. To do this put the following line of code in your fxmanifest.lua under server_scripts:

server_scripts {
    '@oxmysql/lib/MySQL.lua',
    'other_server_script.lua'
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.