I'm using PHP and CodeIgniter. I ran a query using the following script:
$query = $this->db->query('select login_id, date_created from prjsite_login');
$row = $query->result();
print_r($row);
The result of the print_r is:
Array ( [0] => stdClass Object ( [login_id] => admin [date_created] => 2018-04-04 13:18:42 ) )
Which is correct. Thou when I tried to fetch 1 object or value from stdClass using the following script:
echo $query->login_id;
I received an error below:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: pages/home.php
Line Number: 21
Backtrace:
File: C:\xampp\htdocs\BMI_PRJSITE\application\views\pages\home.php Line: 21 Function: _error_handler
File: C:\xampp\htdocs\BMI_PRJSITE\application\controllers\Pages.php Line: 11 Function: view
File: C:\xampp\htdocs\BMI_PRJSITE\index.php Line: 315 Function: require_once
What am I doing wrong?
TIA