阻止特定的 mysqli_fetch_assoc() 发送警告
我使用了一个表现得很奇怪的特定查询:在我的本地环境中,它运行完美并且不发送任何警告。在网上,查询本身工作正常,但是,mysqli_fetch_assoc($result) 正在生成“mysqli_fetch_assoc() 期望参数 1 为 mysqli_result,给出布尔值”警告。
我从未发生过导致此警告的查询,并且从数据库中获得了正确的信息。这就是为什么我倾向于相信问题不在代码中。
有没有一种方法可以仅关闭针对该特定查询的警告?
编辑-
问题已解决。
这对我来说真的很奇怪,但问题是 dojo.js 的脚本 src 路径不正确。 我不知道连接是什么,但修复路径可以防止 mysqli 警告。
I use a specific query that is acting weird: On my local environment, it works perfect and sends no warning. Online, the query itself works fine, however, mysqli_fetch_assoc($result) is producing the 'mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given' warning.
I never occured a query that was causing this warning AND got the right info from the DB. This is why I tend to believe the problem is not in the code.
Is there a way to shut off the warnings only for this one specific query?
EDIT -
PROBLEM SOLVED.
it is really strange to me, but the problem was an incorrect script src path for dojo.js.
I have no idea what's the connection, but fixing the path prevented mysqli warnings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在调用
mysqli_fetch_assoc
之前,您应该检查是否$result == false
。通常,您首先通过检查 mysqli_connect_errno() 来捕获它,但一般习惯用法是在获取行之前主动检查You should be checking if
$result == false
before you callmysqli_fetch_assoc
. Generally you catch it first by checkingmysqli_connect_errno()
but the general idiom is to proactively check before fetching rows