• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fatal error: Call to a member function to() on a non-object in /hermes/bosweb/web200/b2009/ipg.agrobengalcom/shopnodinga

I use same code for sending email in 2 different controller. First one works fine for me but second one shows me the following error.
Quote:Fatal error: Call to a member function to() on a non-object in /hermes/bosweb/web200/b2009/ipg.agrobengalcom/shopnodinga/application/controllers/mist.php on line 114

here is portion of my controller code where i am getting error

$this->load->library('email');echo $_POST['email'];//Echo shows perfect email address
$this->email->to($_POST['email']); //error indicate this line
$this->email->from('[email protected]','Shopno-Dinga.Com');
$this->email->subject('Update MIST Address Book using this information.');
$message = "test";

what's wrong here ? help me to figure out.

I just posted some rubish - do not mind it Smile


Well, what happens when you var_dump($this->email) right before the call to send()?

Ops!! program execution stopped and give fatal error at line:
so program execution doesn't reached at var_dump
if i put var_dump befor ->to(....); then it shows

try $_REQUEST['email'] instead?

Sounds like the email class isn't loading... Hm...

Something funny going on in that controller? Using modules or anything?


@srpurdy: Same result for _REQUEST
i don't use any modules. and it's really surprising. same code works fine in different controller.
when i use var_dump($this->load->library(‘email’)); as
var_dump($this->load->library('email')); // it shows NULL
$this->email->from('[email protected]','Shopno-Dinga.Com');
$this->email->subject('Update MIST Address Book using this information.');
$message = "test";
it shows NULL and error remain same
Fatal error: Call to a member function to() on a non-object in /hermes/bosweb/web200/b2009/ipg.agrobengalcom/shopnodinga/application/controllers/mist.php on line 147

Set logging to "4" in config.php, return your controller to its original state, run the controller, read the log file. There may be something there that will help you figure it out. Do a debug message right before the expected error if you have a hard time following the log.

It's not loading the email class, it's hard to say why without more information.

Smile Works Great your idea.
I found my mistake. Loading email library twice. once from autoload and another from controller. i remove email from autoload and now it works fine.
thanks Madmartigan1

Still it is strange behavior. You should be able to load the class as many times as you want, but you figured out your problem and that's what matters. Now time to get back to work Smile

Update: It's probably better that you don't autoload the email class anyways. It is the #1 biggest library in Codeigniter.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.