gpt4 book ai didi

mysql - 错误参数 #1 到 'ipairs'(预期表,得到 bool 值)

转载 作者:行者123 更新时间:2023-11-29 10:25:26 25 4
gpt4 key购买 nike

控制台错误;

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)

最佳答案

什么时候 exports.mysql:select('advertisements') 失败返回 boolean 并且您不能在 boolean 上使用 ipairs值,因为 ipairs 可以与表一起使用。

为什么exports.mysql:select('advertisements')调用失败?

因为在表格周围加上引号,因为它们不是字符串并且应该这样做

exports.mysql:select("SELECT * FROM 'advertisements' WHERE <something>") 

关于mysql - 错误参数 #1 到 'ipairs'(预期表,得到 bool 值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48388448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com