CodeIgniter Forums
Email Library Problem remains unsolved - SOLVED - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Email Library Problem remains unsolved - SOLVED (/showthread.php?tid=8189)

Pages: 1 2


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]FuzzyJared[/eluser]
When I try to use the email library in my controller brings the site to a screeching hault.


Code:
function _sendEmail($email, $subject, $message)
    {
        $tobj =& get_instance();
        $tobj->load->library('email');
        $tobj->email->clear();
    }

I am looking at my error logs and find the following.

PHP Fatal error: Call to a member function clear() on a non-object

Has anyone seen this happen or have any options for me to try in resolving this?


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]FuzzyJared[/eluser]
SOLVED !!!

I found out what the problem was. I had $this->email declared earlier for the user's email address. Changing it to
Code:
$this->my_email
solved it..... I am not sure why that would be a problem. $this->email should be different than $tobj->email.


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]Derek Jones[/eluser]
You're referencing the same super object...

Code:
$tobj =& get_instance();



Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]FuzzyJared[/eluser]
hmmmm... well that sucks. I have to go through my controllers to ensure that I am not using $this->email.


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]Derek Jones[/eluser]
Why are you wanting a separate object in the first place?


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]j_emerick[/eluser]
[quote author="FuzzyJared" date="1210294135"]SOLVED !!!

I found out what the problem was. I had $this->email declared earlier for the user's email address. Changing it to
Code:
$this->my_email
solved it..... I am not sure why that would be a problem. $this->email should be different than $tobj->email.[/quote]

Actually, when you do this:
Code:
$tobj =& get_instance()


$tobj->email is exactly the same as $this->email as you are setting $tobj up as a reference to the CI super-object (i.e. $this)


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]FuzzyJared[/eluser]
I was using $this->email as a variable within the constructor so I could call it without querying it when needed.


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]Derek Jones[/eluser]
[quote author="FuzzyJared" date="1210295063"]I was using $this->email as a variable within the constructor so I could call it without querying it when needed.[/quote]

Do you mean that you are loading the email library in your controller's constructor? If so, that still doesn't explain why you are needing a separate object.


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]FuzzyJared[/eluser]
The controller is an account controller "my_account", and I was using $this->email as a variable to quickly retrieve the user's email address within that controller.

Make sense?


Email Library Problem remains unsolved - SOLVED - El Forum - 05-08-2008

[eluser]Derek Jones[/eluser]
Ah yes, I see, you had a class property identically named to the library. Might I suggest $this->email_address so there's no collisions? :-D