CodeIgniter Forums
Problem with Codes - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Problem with Codes (/showthread.php?tid=66569)

Pages: 1 2

RE: Problem with Codes - Jay01 - 11-08-2016

(11-08-2016, 12:04 AM)Wouter60 Wrote: In your attachment, it looks like you name your controller "Controller.php". This is a recipe for trouble. Controller is a reserved name in CI for a specific type of class.
It's also very odd to address to a page on your website with a URL like, isn't it?
Rename the controller to Invoices.php. Don't forget to change the class name inside the controller too.

Your controller function starts with this line:
PHP Code:

It should be:
PHP Code:

Next, in your controller, you are loading this view:
PHP Code:

CI is looking for a view named application/views/backend/index.php.
But the view you mention in the attachment is named debtor_print_view.php. You can't expect your application to work that way.

Also, in your model, you have this line:

PHP Code:
$this->db->from('invoice '); 

Remove the space character after invoice, because the Query Builder will try to open a table named "invoice ", which most likely not exists.

Last but not least, your view has a bunch of wrong code. Remove all of it. Just put this in your view, to test if the controller passes the data correctly:
PHP Code:
echo '<pre>';
print_r($get_debtors);   //$get_debtors is passed by the controller via $page_data['get_debtors'];
echo '</pre>';

Finally, run your application and call the url
I sincerely appreciate your time and efforts in getting this View program work I observed after putting these statements in the Controller 


        $page_data['get_debtors'] = $this->invoices_model->get_debtors;
it blows up giving me this message

he localhost page isn’t working

localhost is currently unable to handle this request.
if I remove the statements above my program will run appropriately.

Thank you very much in advance looking into this issues for me

RE: Problem with Codes - Wouter60 - 11-08-2016

Insert parentheses () after ->get_debtors:
PHP Code:
$page_data['get_debtors'] = $this->invoices_model->get_debtors();