Welcome Guest, Not a member yet? Register   Sign In
another situation which cause Fatal error: Call to a member function on a non-object
#1

[eluser]EugeneS[/eluser]
tried to find the solution but i cant so here is description of the problem:

my home PC: php 5.x Apache 2.x windows
my work PC: php 5.x Apache 2.x windows

at work i run this code without any problems:

Code:
class Cart extends Controller {
    function Cart()
    {
        parent::Controller();
        ..........
        ..........
    }

    function Process()    
    {
        .........
        $this->load->library('somelibrary');
        .........
        $this->somelibrary->somemethod();

    }
}

BUT at home i receive this error:
Fatal error: Call to a member function somemethod() on a non-object in ......

this code start working at home only when i load library (or model) inside constructor but not inside any method Sad

any ideas ? i have no idea what the problem :\ any tricks to not change php config file (probably this difference depend on php configuration ) because i do not know where my site will be installed ...

sure i can load library in constructor so this will work everywhere but i do not want to do so when i use this library only in one method.... no need to load it all the time.

the same problem with loading models.
#2

[eluser]coolfactor[/eluser]
Is the code identical on each machine?
Same version of CodeIgniter?

The symptoms you describe have been discussed here before, where objects loaded in the constructor don't get saved to the controller instance properly. The situation is rare and not normal.

How are you running Apache/PHP on each of the machines?
#3

[eluser]EugeneS[/eluser]
[quote author="coolfactor" date="1186955635"]Is the code identical on each machine?
Same version of CodeIgniter?

The symptoms you describe have been discussed here before, where objects loaded in the constructor don't get saved to the controller instance properly. The situation is rare and not normal.

How are you running Apache/PHP on each of the machines?[/quote]

on home PC where it doesnt work php loaded as module
LoadModule php5_module "c:/www_server/php/php5apache2_2.dll"

at work the same situation i load php as a module
LoadModule php5_module "C:/www_server/php/php5apache2_2.dll"


CI versions and code in general are identical (copy/paste was used)

CI - latest version.
#4

[eluser]EugeneS[/eluser]
any ideas guys ?
#5

[eluser]johnwbaxter[/eluser]
Have you turned php error reporting up to full?

Can you actually print the error you get verbatim for us?
#6

[eluser]EugeneS[/eluser]
[quote author="audiopleb" date="1187012001"]Have you turned php error reporting up to full?

Can you actually print the error you get verbatim for us?[/quote]

exact error is shown above or you need to know row number Smile ?
#7

[eluser]johnwbaxter[/eluser]
I just wanted to know if there was more error than that to be honest!
#8

[eluser]EugeneS[/eluser]
[quote author="audiopleb" date="1187123796"]I just wanted to know if there was more error than that to be honest![/quote]


------------------------------------
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Cart::$validation

Filename: controllers/cart.php

Line Number: 49
-------------------------------------

Fatal error: Call to a member function set_rules() on a non-object in C:\www_server\Apache\htdocs\mysite\system\application\controllers\cart.php on line 49
#9

[eluser]sparkling tux[/eluser]
BTW, Windows installation isn't responsible for this bug. I'm experiencing the same here http://v60test.valuehost.ru/pi.php
#10

[eluser]Michael Wales[/eluser]
Make sure the Validation library actually exists in your installation?




Theme © iAndrew 2016 - Forum software by © MyBB