• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to get property of non-object

#1
Hello, I am trying to pass a function through another array, but this indicates the following message

Code:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: controllers/Home.php
Line Number: 60
Backtrace:
File: /storage/ssd4/361/2007361/public_html/application/controllers/Home.php
Line: 60
Function: _error_handler
File: /storage/ssd4/361/2007361/public_html/index.php
Line: 315
Function: require_once

But when I do a print_r in the array, I get the values, but I can not get that value.


This is a code:

PHP Code:
public function verifySession()
    {
        
$this->load->library('session');

        if (empty(
$this->session->userdata('number'))){
            
$code ;            
        }else{
            
$code $this->session->userdata ['number'];
        }            
        
        
$query $this->db->query('SELECT * FROM users WHERE code = '.$code.' ');
        
$row $query->row();
        
        
$activo $row->activated;

        
$activado = array('verificacion' => $activo );

        return 
$activado;
        
    } 


PHP Code:
public function index()
    {

        
$data['ayb_link'] = $this->link_ayb;
        
$data['mantenimiento_link'] = $this->link_mantenimiento;
        
$data['recepcion_link'] = $this->link_recepcion;
        
$data['title'] = $this->title  

        print_r
($this->verifySession()); 

        print 
 $this->verifySession()->activado ['verificacion'];


        
$this->load->view('head/header');
        
$this->load->view('home' $data);
        
$this->load->view('footer/footer');

    } 
Reply

#2
(06-25-2017, 06:21 AM)juanrapma Wrote: Hello, I am trying to pass a function through another array, but this indicates the following message

Code:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: controllers/Home.php
Line Number: 60
Backtrace:
File: /storage/ssd4/361/2007361/public_html/application/controllers/Home.php
Line: 60
Function: _error_handler
File: /storage/ssd4/361/2007361/public_html/index.php
Line: 315
Function: require_once

But when I do a print_r in the array, I get the values, but I can not get that value.


This is a code:

PHP Code:
public function verifySession()
 {
 
$this->load->library('session');

 if (empty(
$this->session->userdata('number'))){
 
$code 
 }else{
 
$code $this->session->userdata ['number'];
 } 
 
 
$query $this->db->query('SELECT * FROM users WHERE code = '.$code.' ');
 
$row $query->row();
 
 
$activo $row->activated;

 
$activado = array('verificacion' => $activo );

 return 
$activado;
 
 } 


PHP Code:
public function index()
 {

 
$data['ayb_link'] = $this->link_ayb;
 
$data['mantenimiento_link'] = $this->link_mantenimiento;
 
$data['recepcion_link'] = $this->link_recepcion;
 
$data['title'] = $this->title  

 print_r
($this->verifySession()); 

 print 
 $this->verifySession()->activado ['verificacion'];


 
$this->load->view('head/header');
 
$this->load->view('home' $data);
 
$this->load->view('footer/footer');

 } 

Try this:
$activado = $this->verifySession();
print  activado ['verificacion'];
Practice | Practice | Practice
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.