![]() |
Undefined property - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Undefined property (/showthread.php?tid=72412) |
Undefined property - suchanon - 12-16-2018 I think the program is correct, but it appears that it is an error. Please someone help me. A PHP Error was encountered Severity: Notice Message: Undefined property: mysqli::$ProductID Filename: controllers/ProductsUI.php CI_Model: PHP Code: function get_product(){ CI_Controller: PHP Code: $str = ''; RE: Undefined property - donpwinston - 12-16-2018 maybe $row->ProductID should be $row->productid RE: Undefined property - dave friend - 12-16-2018 The problem is this line doesn't return what you think it does PHP Code: return $this->db->get('product'); You need to Generate Query Results from the returned value - they cannot be read directly. You need something along these lines PHP Code: $this->load->model('Product'); Or, you could have the model return an actual result set PHP Code: function get_product() Then your controller code would work as shown in your original post. RE: Undefined property - suchanon - 12-16-2018 Thank for dave friend. i use this code. PHP Code: $rows = $this->Product->get_product()->result(); A PHP Error was encountered Severity: Warning Message: A non-numeric value encountered Filename: controllers/ProductsUI.php Line Number: 32 Backtrace: File: C:\xampp\htdocs\accounting\application\controllers\ProductsUI.php Line: 32 Function: _error_handler PHP Code: <td>'.$row->Cost.'</td> RE: Undefined property - dave friend - 12-17-2018 I had not looked closely at the code in the loop. Here's my opinion on how it should be written PHP Code: foreach($this->Product->get_product() as $row) RE: Undefined property - suchanon - 12-17-2018 dave friend The result is the same. RE: Undefined property - dave friend - 12-17-2018 (12-17-2018, 08:22 PM)suchanon Wrote: dave friend Did you change PHP Code: $str += 'tr role="row"> to PHP Code: $str .= "tr role='row'> Look closely they are not the same. The most important bit being $str += changed to $str .= RE: Undefined property - suchanon - 12-17-2018 Thank you dave friend. |