bad argument #1 to #39;ipairs#39; (table expected, got boolean)(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(需要表,得到布尔值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:'ipairs' 的错误参数 #1(需要表,得到布尔值)
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
