![](/img/trans.png)
[英]PHP Catchable fatal error: Argument 1 passed to must be of the type array, null given, called in on line 208 and defined
[英]Catchable fatal error: Argument 1 passed to … must be an instance of …, boolean given, called in … on line … and defined in … on line
我已将CMS添加到服务器。 我只是想知道为什么我在页面上不断收到此错误以购买订阅。
这是错误;
Catchable fatal error: Argument 1 passed to ObjectArray::fromMySQLiResult() must be an instance of
mysqli_result, boolean given, called in
C:\inetpub\wwwroot\model\FactoryObjects\User.php on line 71
and defined in C:\inetpub\wwwroot\lib\ObjectArray.php on line 284
第71行包含以下内容;
public function getOrders() {
$objectArray = new ObjectArray();
$result = $this->getConnection()->query("SELECT * FROM vip_orders WHERE user_id =
'" . $this->id. "'");
$objectArray->fromMySQLiResult($result); (<Line 71<)
return $objectArray;
}
284行包含以下内容;
public function fromMySQLiResult(mysqli_result $result) (<Line 284<)
{
$this->clear();
while ($row = $result->fetch_object())
{
$this->add($row);
}
return $this;
}
如果您需要其他任何信息来帮助我解决此错误,请告诉我!
谢谢!
(注意:对于那些提供帮助的人,请您解释一下究竟是什么问题?例如,该功能是什么以及为什么它不起作用,谢谢。)
您对fromMySQLiResult(mysqli_result $result)
定义指出,该函数需要mysqli_result
类型的参数。 但是,您传递的是mysqli :: query()的结果,如果失败,该结果也可能是布尔类型。
为避免该错误,请确保$result
实际上是与文档中的示例类似的查询结果:
if ($result) {
$objectArray->fromMySQLiResult($result);
} else {
// handle error
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.