执行此功能时出错 [英] Error during execution of this function

查看:135
本文介绍了执行此功能时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Possible Duplicate:
Message: Invalid argument supplied for foreach in CodeIgniter

继续操作:消息:CodeIgniter中为foreach提供的参数无效

这是函数,$ data来自...。

This is the function, from which the $datais coming..

function getSearchedUniversityTab($country, $state, $level, $degType) {
      $query = $this->db->query("SELECT `university`.`uniId`, `university`.`name`
                                FROM (`university`)
                                inner JOIN (select degCollege, degType, count(*) as cnt  from degree where `degType` =  '$degType'  group by degCollege) clg
                                ON clg.`degCollege` = `university`.`uniId` 
                                WHERE `country` =  '$country'
                                AND `state` =  '$state'");
      $result = $query->result_array();

      foreach($result as $row)
      {
        $data[] = $row;
      }
      return $data;
      $this->db->close();  
   }


推荐答案

$ c> result 返回空
更改为

Most probable your result is returning empty Change to

function getSearchedUniversityTab($country, $state, $level, $degType) {
      $query = $this->db->query("SELECT `university`.`uniId`, `university`.`name`
                                FROM (`university`)
                                inner JOIN (select degCollege, degType, count(*) as cnt  from degree where `degType` =  '$degType'  group by degCollege) clg
                                ON clg.`degCollege` = `university`.`uniId` 
                                WHERE `country` =  '$country'
                                AND `state` =  '$state'");
      $result = $query->result_array();
     if(count($result) > 0 ) {
      foreach($result as $row)
      {
        $data[] = $row;
      }

      return $data;
     }else{
       return null;
     }
      $this->db->close();  
   }

这篇关于执行此功能时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆