gpt4 book ai didi

PHP fatal error 帮助

转载 作者:行者123 更新时间:2023-11-29 09:21:28 28 4
gpt4 key购买 nike

我收到以下错误。

Fatal error: Cannot increment/decrement overloaded objects nor string offsets

这是代码。

$mysqli = new mysqli("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT id, label, link_url, parent_id FROM dyn_menu ORDER BY parent_id, id ASC");

if (!$dbc) {
// There was an error...do something about it here...
print mysqli_error();
}

while ($obj = mysqli_fetch_assoc($dbc)) {
if (!empty($obj['parent_id']) == 0) {
echo $parent_menu . $obj['id']['label'] = $obj['label'];
echo $parent_menu . $obj['id']['link'] = $obj['link_url'];
} else {
echo $sub_menu . $obj['id']['parent'] = $obj['parent_id'];
echo $sub_menu . $obj['id']['label'] = $obj['label'];
echo $sub_menu . $obj['id']['link'] = $obj['link_url'];
echo $parent_menu . $obj['parent_id']['count']++;
}
}
mysql_free_result($dbc);

最佳答案

您的 $obj['parent_id'] 是一个字符串(包含数字,例如 "0") - 它不是一个带有 count< 的数组 条目。这会更有意义:

$obj['parent_id']++

另外,这非常令人困惑:

if (!empty($obj['parent_id']) == 0) {

这会更有意义:

if (empty($obj['parent_id'])) {

关于PHP fatal error 帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1625073/

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