I have a function, merge(), in admin.php which is defined by: class admin extends catalog. (catalog is a file with more functions) When I try to call this function from index.php by using $admin->merge I get the error: Call to a member function merge() on a non-object.
Any idea what's going wrong?
Thanks
Call Function in Separate File
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Call Function in Separate File
have you instantiated an object of class admin?
Re: Call Function in Separate File
Thanks! That solved one problem, but created another.
How do you initiate: $this->core->db->run() inside the function merge()? I'm getting the same error when I try to run this function.
How do you initiate: $this->core->db->run() inside the function merge()? I'm getting the same error when I try to run this function.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Call Function in Separate File
Assuming you've instantiated an object of your database class, you pass that object as a parameter into the call to instantiate your admin class, and stick it in one of your admin class attributes.blodder24 wrote:How do you initiate: $this->core->db->run() inside the function merge()? I'm getting the same error when I try to run this function.
That way, it's available to all the methods in your admin class
Re: Call Function in Separate File
Thanks for your help!