首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP+MYSQL编程 » [求助]恳请大家帮忙看看关于array/object的报错  


  作者:yang3123312
  注册时间:2005-06-28
  主题/回复:7/9
  积分:444
  等级:★★☆(五级)
  称号:略有小成

用户联系方式已设置为保密

 

 发表:2005-07-02 01:17:18 阅读 2326 次 回复 2 次 得分1  |   字号 字色
[求助]恳请大家帮忙看看关于array/object的报错
今日又来求助,请多多帮忙!
后台运行时报错如下:
Warning: reset(): Passed variable is not an array or object  in D:\Program Files\Apache Group\Apache2\htdocs\catalog\admin\includes\classes\object_info.php on line 17

Warning: Variable passed to each() is not an array or object in D:\Program Files\Apache Group\Apache2\htdocs\catalog\admin\includes\classes\object_info.php on line 18
我想是传递变量不是要求的数组或者对象,于是我在相应文件中查找,但我觉得传递过去的好像是数组啊,大家帮帮忙,谢谢!
 下面是涉及到的函数定义
[php]
<?php

  class objectInfo {

// class constructor
    function objectInfo($object_array) {
  reset($object_array);
  while (list($key, $value) = each($object_array)) {
    $this->$key = tep_db_prepare_input($value);
  }
    }
  }
?>
[/php]
下面是用到objectInfo类的几处地方(以标号显示):
[php]
1.  $cInfo = new objectInfo($HTTP_POST_VARS);

2.  $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, cd.classification_name, cc.classification_id,c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS_CLASSIFICATION . " cc," . TABLE_CUSTOMERS_CLASSIFICATION_DESCRIPTION . " cd, "  . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.classification_id = cd.classification_id and cd.classification_id = cc.classification_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
    $customers = tep_db_fetch_array($customers_query);
    $cInfo = new objectInfo($customers);

3. $classification_query = tep_db_query("select c.classification_id, cd.classification_name, c.parent_id, c.date_added, c.date_modified from " . TABLE_CUSTOMERS_CLASSIFICATION . " c, " . TABLE_CUSTOMERS_CLASSIFICATION_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_classification_id . "' and c.classification_id = cd.classification_id and cd.language_id = '" . (int)$languages_id . "' order by  cd.classification_name");

 $classification = tep_db_fetch_array($classification_query)

$classification_childs = array('childs_count' => tep_childs_in_classification_count($classification['classification_id']));
    $classification_customers = array('customers_count' => tep_customers_in_classification_count($classification['classification_id']));

    $ccInfo_array = array_merge($classification, $classification_childs, $classification_customers);
    $ccInfo = new objectInfo($ccInfo_array);

4. $customers_query = tep_db_query("select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id, c2c.classification_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a, " . TABLE_CUSTOMERS_TO_CLASSIFICATION . " c2c where c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id and c.customers_id = c2c.customers_id and c2c.classification_id = '" .(int) $current_classification_id . "' order by c.customers_lastname, c.customers_firstname");

$customers = tep_db_fetch_array($customers_query)

$info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");
  $info = tep_db_fetch_array($info_query);

 $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$customers['entry_country_id'] . "'");
    $country = tep_db_fetch_array($country_query);

    $reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");
    $reviews = tep_db_fetch_array($reviews_query);

    $customer_info = array_merge($country, $info, $reviews);

    $cInfo_array = array_merge($customers, $customer_info);
    $cInfo = new objectInfo($cInfo_array);

 [/php]
 
 1#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 1#楼 发表于2005-07-04 16:55:30  评分:1 

可能传递的类型确实都是数组
但是有时候一个数组可能为空,比如你有一个地方是把数据库查询结果作为一个数组传递给构造器。但是如果数据库查询语句执行不成功,或者返回结果为空,那么这个变量可能就不是一个数组,所以传递过去之后可能就会报错。

自己调试一下看看,在每一个传递数组的地方都测试一下,看看这个数组在运行期有没有问题。]
 2#楼  
 
  回复人:yang3123312
  注册时间:2005-06-28
  主题/回复:7/9
  积分:444
  等级:★★☆(五级)
  称号:略有小成

用户联系方式已设置为保密
 2#楼 发表于2005-07-04 22:53:11  评分:× 

好的,谢谢!
经调试错误终于排除 :)
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.015sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版