CodeIgniter Forums
PHP4: Call to a member function on a non-object - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: PHP4: Call to a member function on a non-object (/thread-8371.html)



PHP4: Call to a member function on a non-object - El Forum - 05-15-2008

[eluser]Unknown[/eluser]
I developed my application using PHP5. Now I was made to run it on old PHP 4.3.8

It returns an error "Call to a member function on a non-object" on lines

Code:
$this->load->model('selecty_model');
            
if (!$this->selecty_model->isVyrobce($vyrobce)) {$vyrobce = "";}
if (!$this->selecty_model->isProjektor($projektor)) {$projektor = "";}

I know it it's probably my mistake. But what is wrong?
I grow up on PHP5, I don't know PHP4 pretty much.

Thanks for your help


PHP4: Call to a member function on a non-object - El Forum - 05-15-2008

[eluser]gtech[/eluser]
is the model loading correctly? you could put some dbug in.


PHP4: Call to a member function on a non-object - El Forum - 05-15-2008

[eluser]mironcho[/eluser]
How your model looks like? Do you use PHP5 specific magic methods (__construct(), __destruct(), etc...)?


PHP4: Call to a member function on a non-object - El Forum - 05-15-2008

[eluser]Unknown[/eluser]
On PHP5 it works fine.

The model:

Code:
<?php
class Selecty_model extends Model {

    function Selecty_model()
        {
            parent::Model();
        }

    function isVyrobce($vyrobce){
            $CI =& get_instance();
....
....
....

I really don't know... :-(


PHP4: Call to a member function on a non-object - El Forum - 05-15-2008

[eluser]gtech[/eluser]
If I was in your shoes start from basics, as what you have provided looks ok.

create a fresh controller and model
then create a method in the model that just has the line echo "hello";
then load and call the method from the controller.

you can then satisfy your self that you can load models correctly.

My suspicion is that your model has php5 specific code (maybe you are using a php4 reserved word) in it somewhere and so it is not loading, turn your log_threashold on to 4 by setting the config parameters and see if you get any clues in the log.