doupu9251 2016-04-29 00:46
浏览 45
已采纳

Code Igniter(类stdClass的对象无法转换为字符串)erro

this is my model:

function Countosweb(){
    $sql="SELECT count(*) FROM `os` WHERE `status`='PENDIENTE ASIGNAR TÉCNICO'";
    return $this->db->query($sql)->row();
}

this is my controller:

public function indexp() {
    if((!$this->session->userdata('session_id')) || (!$this->session->userdata('logado'))){
        redirect('mapos/login');
    }
    $this->data['ordensW'] = $this->mapos_model->getOsWeb();
    $this->data['osn']= $this->mapos_model->Countosweb($sql);
    $this->data['ordens'] = $this->mapos_model->getOsAbertas();
    $this->data['produtos'] = $this->mapos_model->getProdutosMinimo();
    $this->data['os'] = $this->mapos_model->getOsEstatisticas();
    $this->data['estatisticas_financeiro'] = $this->mapos_model->getEstatisticasFinanceiro();
    $this->data['menuPainel'] = 'Painel';
    $this->data['view'] = 'mapos/panel';
    //$this->session->set_flashdata('success','mensaje de prueba');
    $this->load->view('tema/alte',$this->data);

}

and this is my view:

<a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <i class="fa fa-bell-o"></i>
                <?php
                if($osn != null){echo '<span class="label label-warning">'.$osn.'</span>';} // this is the line which is occasinating the problem.
                ?>
           </a>

so i got this error:

A PHP ERROR WAS ENCOUNTERED

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename:tema/alte.php

line Number: 67

Please help to find the problem

PD: excuse me, my english is not very good

  • 写回答

3条回答 默认 最新

  • doujinai2183 2016-04-29 13:30
    关注

    thanks all for helping me, i solved it:

    i changed this:

    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <i class="fa fa-bell-o"></i>
                <?php
                if($osn != null){echo '<span class="label label-warning">'.$osn.'</span>';} // this is the line which is occasinating the problem.
                ?>   
    </a>
    

    For this:

    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    <i class="fa fa-bell-o"></i>
                    <?php
                    if($osn != null){
                      foreach($osn as $on){echo'<span class="label label-warning">'.$on.'</span>';} 
                    }
                    ?>
    </a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里