本文介绍了'ipairs' 的错误参数 #1(需要表,得到布尔值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
控制台错误;
117: call: failed to call 'mysql:select' [string "?"]
117: bad argument #1 to 'ipairs' <table expected, got boolean>
函数;
function openAdvertisements( player, command )
local advertisements = { } --These will hold our advertisements to send to the client and populate our advertisement tables.
if not player then player = source end
--Fetch all of the advertisements from the database
for _, ad in ipairs( exports.mysql:select('advertisements') ) do
if tonumber( ad.expiry ) >= tonumber( getRealTime().timestamp ) then --Check if the advertisement has expired, delete it if so.
ad.author = exports.mysql:select_one( "characters", { id = ad.created_by } ).charactername
table.insert( advertisements, ad )
else
deleteAdvertisement( ad.id )
end
end
triggerClientEvent( player, resourceName .. ":display_all", root, advertisements, exports.integration:isPlayerAdmin( player ) ) --Send the advertisements to the client to create the GUI.
end
第 117 行;对于 _, ipairs 中的广告(exports.mysql:select('advertisements')) 做离开Cs(cid)
line 117; for _, ad in ipairs( exports.mysql:select('advertisements') ) do leaveCs(cid)
推荐答案
何时exports.mysql:select('advertisements')
失败返回 boolean
并且你不能在 boolean
上使用 ipairs
值,因为 ipairs
可以与表一起使用.
When
exports.mysql:select('advertisements')
failed return boolean
and you can't use ipairs
on boolean
value because ipairs
can use with tables.
为什么 exports.mysql:select('advertisements')
调用失败?
因为在表格周围加上引号,因为它们不是字符串应该这样做
because put quotes around tables, for they are not strings and should do that like
exports.mysql:select("SELECT * FROM 'advertisements' WHERE <something>")
这篇关于'ipairs' 的错误参数 #1(需要表,得到布尔值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!