Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to a member function insert() on a non-object in ?
#20

[eluser]Phil Sturgeon[/eluser]
Right, guys hold on a minute.

This error originally started because the database library was not being loaded. Now everybody is getting a little confused between 1.7.x and 2.0.x and providing really bad advice.

1.7.x

Code:
class Invest extends Controller {


        function Invest()
        {
             parent::Controller();
             // Your own constructor code
        }

You can use function __construct() if you like, but don't use both!

2.0.x

Code:
class Invest extends CI_Controller {


        function __construct()
        {
             parent::__construct();
             // Your own constructor code
        }

There you have it. Notice the __construct() is used EVERYWHERE now for constructors instead of PHP4 style syntax. Same for Models (which now extend CI_Model).

Also, I am grateful that somebody shared my BASE_URL code, but why? That code is all automatic in CI 2.0 now if you do not set a base_url, it sets one for you.


Messages In This Thread
Fatal error: Call to a member function insert() on a non-object in ? - by El Forum - 02-17-2011, 12:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB