php - Oscommerce如何解决,警告:sizeof(): Parameter must be an array or an object that implement Countable
问题描述
我安装了最新版本的 OSCommerce 框架。在后端类别/产品错误显示如下:
警告:sizeof():参数必须是在 C:\xampp\htdocs\oscommerce\catalog\admin\includes\functions\general.php 第 93 行中实现 Countable 的数组或对象
我尝试使用is_array()
但count()
仍然无法正常工作,下面是代码
function tep_get_path($current_category_id = '') {
global $cPath_array;
if ($current_category_id == '') {
$cPath_new = implode('_', $cPath_array);
} else {
if (sizeof($cPath_array) == 0) {
$cPath_new = $current_category_id;
} else {
$cPath_new = '';
$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where
categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
$last_category = tep_db_fetch_array($last_category_query);
$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where
categories_id = '" . (int)$current_category_id . "'");
$current_category = tep_db_fetch_array($current_category_query);
if ($last_category['parent_id'] == $current_category['parent_id']) {
for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
} else {
for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
}
$cPath_new .= '_' . $current_category_id;
if (substr($cPath_new, 0, 1) == '_') {
$cPath_new = substr($cPath_new, 1);
}
}
}
return 'cPath=' . $cPath_new;
}
解决方案
我在文件中添加了下面的代码,只是给出错误的行。
if ($cPath_array == null) {
$cPath_array = array();
}
它解决了我的错误
推荐阅读
- c# - 如何将 C# 项目与放置在服务器(非本地网络)上的 Access 数据库连接以进行编辑和查看?
- paypal - 集成 Paypal 支付和发票 API
- gatsby - 如何将 AMP Story 添加到 Gatsby 应用程序
- c# - EF Core:在可选外键中将 Guid.Empty 解释为 null
- mongodb - 如何在 Mongo 查询中投影子元素?
- asp.net - asp:Button disabled false for select on click 不起作用
- sql - 不正确的表定义:只能有一个自动列,并且必须定义为键
- javascript - 使用 MongoDB 从 JSON 中删除属性
- ads - AdManager - 如何衡量可见度
- c# - 如何在解决方案中查找所有 AutoMap 配置文件并注册它们