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

[eluser]anna16[/eluser]
@learn codeigniter

thanks, i did what you said.
but I'm still getting the same error.

Fatal error: Class 'CI_Controller' not found


thanks in advanced.
#12

[eluser]anna16[/eluser]
by the way this is my site controller codes,
Code:
<?php
class Site extends CI_Controller
{
    function __construct()
    {
        parent::Controller();
        $this->load->library('session');
        $this->load->helper('form');
    $this->load->helper('url');
    $this->load->model('membership/membership');
    }

  
  function register_form()
  {
       $this->load->view('membership/register_form');
  }

  function validate_data()
  {
  
  }

    function register_account()
    {
        $data = array(
            'email' => $this->input->post('email'),
            'username' => $this->input->post('username'),
      'password' => $this->input->post('password'),
      'confirm' => 'no',
        );
        
        $this->membership->add_record($data);
    $this->load->view('membership/register_success');
    }


/* These are function tests. */  
  function register_success()
  {
       $this->load->view('membership/register_success');
  }


}
//end of class
#13

[eluser]LuckyFella73[/eluser]
Hi Anna,

maybe try this
Code:
class Site extends CI_Controller
{
    function __construct()
    {
        parent::__construct(); // changed this line
        $this->load->library('session');
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->model('membership/membership');
#14

[eluser]anna16[/eluser]
thanks lyckyfella73

but it did not worked.

I checked the libraries folder but there is no CI_Controller class?
#15

[eluser]LuckyFella73[/eluser]
hmm, in my application it works that way but I extended the
CI controller.

The welcome controller from the CI2 package looks like that:
Code:
class Welcome extends CI_Controller {

    function Welcome()
    {
        parent::CI_Controller();
    }
so maybe you have to write it like:
Code:
class Site extends CI_Controller
{
    function Site() // here
    {
        parent::CI_Controller(); // and here
        $this->load->library('session');
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->model('membership/membership');
#16

[eluser]anna16[/eluser]
nah, it did not worked also.

WOW what an error...

I'll try to figure this out later.
#17

[eluser]Learn CodeIgniter[/eluser]
Correct way!
Code:
class Blog extends CI_Controller {

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

Check your paths in the index.php and make sure they are set to
the right folders for system and application.
#18

[eluser]Unknown[/eluser]
None of what appears in these comments has worked for me. I'm just trying to follow the basic tutorial video and keep getting

Code:
Fatal error: Class 'Controller' not found in /home2/something/public_html/something-else/system/application/controllers/invest.php on line 3


Or
Code:
Class 'CI_Controller'
, same problem.

Here's my code:

Code:
<?

class Invest extends CI_Controller {


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



    function Invest()
    {
        parent::Controller();

    }



    function index()
    {

        //$this->load->view('investor_browse_page');
        $this->Page_Display();
    }
    


    function Page_Display()
    {
        $data[1] = 'poop';
        $data[2] = 'pee';
        $data[3] = 'flatus';

        $this->load->view('investor_browse_page', $data);

    }


} //end class

?>



You can see the detritus of many attempts at making this work.
#19

[eluser]InsiteFX[/eluser]
Delete this function you no longer need it!
Code:
function Invest()
{
    parent::Controller();

}

InsiteFX
#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.




Theme © iAndrew 2016 - Forum software by © MyBB