MySQL: problem how to retreive data (identifier)

Hello, I am trying to understand how to use MySQL in lua, to get values from the Database.
My attempt was to get the users firstname by checking against the identifier.

My local license already holds the identifier as it is stored inside the database.
The call to MySQL should happen inside my AddEventHandler (which is setup and working).

The MySQL line gives me the error: attempt to index a nil value (Global ‘MySQL’) and I don’t understand why.

-- local license already holds the correct identifier to check for

		local fname = ""
		MySQL.Async.fetchAll('SELECT firstname FROM users WHERE identifier = @license', {}, function(result)
		fname = result
		print("Firstname is: ", fname)		
		end)

Inside my resource-file:


server_scripts{
 '@mysql-async/lib/MySQL.lua',
 'server.lua'
 
}

I think I found it!

Solution:

	MySQL.Async.fetchAll('SELECT firstname FROM users WHERE identifier = @license', {['@license'] = license}, function(result)
		userName = result[1].firstname
		print("Account dataname is", userName)
		
	end)

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