0

I have a model, controller and view file.

Model

  public function isletme_bilgileri($yetki){
    $this->db->select('*');
    $this->db->from('isletme_bilgileri');
    $this->db->where($yetki);
    $query=$this->db->get();
   return  $result = $query->result();    

Controller

 $this->load->model('Bilgi_Model');
          $result = $this->Bilgi_Model->isletme_bilgileri($this->session->user_sess['yetki']);
          $isletme_bilgileri=array(
          'id'              =>$result->id,
          'isletme_adi'     =>$result->isletme_adi,
                  );
          
   
    // işletme bilgisi Çekildi //        
            
    $this->load->view('admin/_header', $isletme_bilgileri);

View (_header.php)

<span class="logo-lg"><b><?=$this->isletme_bilgileri('isletme_adi')?></b></span>

But I'm not getting the data in the view file.

Error

Severity: Notice

Message: Trying to get property of non-object

Filename: admin/Home.php

Line Number: 19

Backtrace: File: C:\wamp64\www\apartman_ys\application\controllers\admin\Home.php Line: 19 Function: _error_handler

File: C:\wamp64\www\apartman_ys\index.php Line: 315 Function: require_once

Community
  • 1
  • 1
Fatih Ay
  • 19
  • 3

4 Answers4

0

CI passes variables to view as an assoc array:

$data = array('car' => 'blue');
$this->load->view('index', $data);

Then in your view:

<span><?=$car;?>//outputs blue</span>
Kisaragi
  • 2,198
  • 3
  • 16
  • 28
0

This is problem with your model. Check whether the row is being returned on for the query you are executing. You can get the last executed query in CI using this.

$this->db->last_query();

echo this in your controller copy the query and paste it into phpMyAdmin or Whatever you are using.

0
In Controller
$data['isletme_bilgileri']=array(
          'id'              =>$result->id,
          'isletme_adi'     =>$result->isletme_adi,
                  );
$this->load->view('admin/_header', $data)

<span class="logo-lg"><b><?=$isletme_bilgileri['isletme_adi']?></b></span>
0

yes ı fix it $result variable must be $result[0]

now the actual code is this ;

$result = $this->Bilgi_Model->isletme_bilgileri();
            $data=array(
                'id'=>$result[0]->id,
                'isletme_adi'=>$result[0]->isletme_adi,
                'isletme_kisa_ad'=>$result[0]->isletme_kisa_ad
            );
Fatih Ay
  • 19
  • 3