Attempt to index a nil value (global 'mySQL')

Hello,
I have a problem with my script. I tried to do a SQL request in the esx_property server script. In the script their are already some SQL requests.

My Code:

ESX.RegisterServerCallback('esx_property:getAlreadyBought', function(temp, cb)
	print(temp)
	local x = temp

	mySQL.Async.fetchAll('SELECT COUNT(*) as count FROM owned_properties WHERE name = @x', {}, function(count)
		cb(count)
	end)
end)

If I trigger the the callback from the client I get following Error:

SCRIPT ERROR: @esx_property/server/main.lua:334: attempt to index a nil value (global 'mySQL')
> ref (@esx_property/server/main.lua:334)
> TriggerServerCallback (@es_extended/server/functions.lua:154)
> handler (@es_extended/server/common.lua:71)

line 334 is the line with:

mySQL.Async.fetchAll('SELECT COUNT(*) as count FROM owned_properties WHERE name = @x', {}, function(count)

I tried the MYSQL request in phpmyadmin, and it worked as expected:

SELECT COUNT(*) as count FROM owned_properties WHERE name = "NorthConkerAvenue2045"

count
  1

I hope someone can help me. I don’t know if you need more informations, but if so, i will send them.

AimWolf

1 Like

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