Imran Ali
Imran Ali

Reputation: 97

Fatal Error in CodeIgniter

I am facing a Fatal error:

Class 'Controller' not found in D:\wamp\www\CodeIgniter\application\controllers\blog.php on line 3

I am typing write and i watched so many tutorials they are also typing beginning code like this i tried a lot to find out but got no reason

Upvotes: 0

Views: 1611

Answers (2)

Joris Ooms
Joris Ooms

Reputation: 12038

Are you using CI 2.O? Did you by any chance write the following in your controller:

class Blog extends Controller { ... }

If you're using CI 2.0, you should use the following:

class Blog extends CI_Controller { ... }

You might have been watching outdated tutorials for CI 1.7.

Reference: http://codeigniter.com/user_guide/general/controllers.html

Make sure to follow the userguide along with whatever tutorials you're following; there's some changes in 2.0 which you should be aware of. You can still follow these tutorials though, just keep your eyes open and compare with the userguide.

Upvotes: 4

Damien Pirsy
Damien Pirsy

Reputation: 25435

What version are you using? if you're using the latest (2.0.2), make sure you use CI_Controller when extending your controller. Seeing you named the file blog.php, your controller should be looking like this

Class Blog extends CI_Controller {

 function index()
{
  // your code...
}

}

Upvotes: 1

Related Questions