Welcome Guest, Not a member yet? Register   Sign In
load is unknown?
#1

[eluser]Firenter[/eluser]
Hi there forums!
I just set up a new site, and I wanted to start from scratch (with CI of course).
I've copied the welcome controller into my own Index controller and created a homepage that should just say 'Welcome!'.
But whenever I try to load the page it gives me this:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Index::$load

Filename: controllers/index.php

Line Number: 7

It seems it's not properly accessing the load view function, the code looks like this:
Code:
$this->load->view('home');

I don't see what I did wrong here, it should just be something simple right?
#2

[eluser]Aken[/eluser]
Paste your entire controller's code. I'm guessing you misspelled something.
#3

[eluser]wiredesignz[/eluser]
Do not use reserved words for Controller naming.

Refer: http://ellislab.com/codeigniter/user-gui...names.html
#4

[eluser]brownmarsh12[/eluser]
Solving for Facebook's "load-error: unknown" error Spent about the last 20 minutes debugging a mysterious error
#5

[eluser]Firenter[/eluser]
Right so the problem was that I forgot the constructor at the beginning of the controller. Simple as that, without the constructor it probably won't know what to do Tongue

Also @wiredesignz you can use index as a controller name, I've done it before and never ran into trouble...
#6

[eluser]wiredesignz[/eluser]
@Firenter, A class constructor is not normally required unless you are carrying out some initiation for the class. PHP5 will automatically run the parent constructor in it's absence.

The reason that your application failed and required an empty __constructor is because the index method is considered to be the constructor if your controller class name is also Index.(prior to PHP5.4)

So the parent constructor was never being called and the Loader was never initialized.

This is why the User Guide makes note of reserved words, to avoid this kind of confusion.
(And possibly with some carry over from PHP4 in some cases)
#7

[eluser]Firenter[/eluser]
Thanks for the explanation, learning new things everyday!




Theme © iAndrew 2016 - Forum software by © MyBB