Hello! The problem would be that I think I give everything right, but the script writes an error.
 
	 
 
	[23:53:12] WARNING: inventory/sourceS.lua:2428: dbPoll failed; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM items ORDER BY dbID DESC LIMIT 1' at line 1
	[23:53:12] ERROR: inventory/sourceS.lua:2428: attempt to index a boolean value
	 
	 
	Thank you in advance for your help!
	 
	local connection = exports.mysql:getConnection()
function giveItem(sourceElement, itemId, amount, data1, data2, data3)
	addItem(sourceElement, itemId, amount, false, data1, data2, data3)
end
function addItem(sourceElement, itemId, amount, slotId, data1, data2, data3)
	if isElement(sourceElement) and itemId and amount then
		itemId = tonumber(itemId)
		amount = tonumber(amount)
		if not itemsTable[sourceElement] then
			itemsTable[sourceElement] = {}
		end
		if not slotId then
			slotId = findEmptySlot(sourceElement, itemId)
		elseif tonumber(slotId) then
			if itemsTable[sourceElement][slotId] then
				slotId = findEmptySlot(sourceElement, itemId)
			end
		end
		if slotId then
			local ownerType = getElementType(sourceElement)
			local ownerId1 = getElementData(sourceElement, "accountid")
			local ownerId = tonumber(ownerId1)
			if tonumber(ownerId) then
				itemsTable[sourceElement][slotId] = {}
				itemsTable[sourceElement][slotId].locked = true
				dbQuery(
					function (qh, sourceElement)
						if isElement(sourceElement) then
							local result = dbPoll(qh, 0, true)[2][1][1]
							if result then
								addItemEx(sourceElement, result.dbID, result.slot, result.itemId, result.amount, result.data1, result.data2, result.data3)
								triggerItemEvent(sourceElement, "addItem", getElementType(sourceElement), result)
								attachWeapon(sourceElement, result.itemId, result.dbID)
							end
						end
					end, {sourceElement}, connection, "INSERT INTO items (itemId, slot, amount, data1, data2, data3, ownerType, ownerId) VALUES (?,?,?,?,?,?,?,?); SELECT * FROM items ORDER BY dbID DESC LIMIT 1", itemId, slotId, amount, data1, data2, data3, ownerType, ownerId
				)
				return true
			else
				return false
			end
		else
			return false
		end
	else
		return false
	end
end
addEvent("addItem", true)
addEventHandler("addItem", getRootElement(), addItem)