Reputation: 2763
Well I have a strange problem in my Codeigniter page. I have a controller class books.php
> <?php
> //echo 'Hello';
> class Books extends CI_Controller{
> function __construct() {
> parent::__construct();
> }
>
>
> function main()
> {
> $this->load->view('main_view');
> }
>
> function input()
> {
> $this->load->view('input_view');
> } } ?>
Now if I point my browser to http://localhost/CodeIgniter/index.php/books
it shows 404 Page not found.
Now If I add a echo 'Hello';
just above the class declaration, it shows hello and at the top of the page and after that line the same 404 error.Is this due to permission roblem. books.php
have 777
permission.
Upvotes: 0
Views: 2828
Reputation: 2313
When accessing:
the default router will actually load up
It is therefore looking for the index method.
Try adding the method or calling either of the method that you have defined:
http://localhost/CodeIgniter/index.php/books/main
http://localhost/CodeIgniter/index.php/books/input
Also, you should refrain from having 777 permissions on your files.
Upvotes: 2
Reputation: 13364
Please try with following code
<?php
> //echo 'Hello';
> class Books extends CI_Controller{
> public function index() {
> echo "check";
> }
>
>
> function main()
> {
> $this->load->view('main_view');
> }
>
> function input()
> {
> $this->load->view('input_view');
> } } ?>
Upvotes: 0
Reputation: 5127
You are missing the index()
function. Refer to CodeIgniter URLs topic in their user guide to find out more about their segment-based approach.
Upvotes: 1
Reputation: 1043
Please create a index function inside your books.php or just for a sake of test just rename main function signature as follows -
function index()
{ $this->load->view('main_view'); }
Upvotes: 0
Reputation: 484
> <?php
> //echo 'Hello';
> class Books extends CI_Controller{
> function __construct() {
> parent::__construct();
> }
>
>
> function index()
> {
> $this->load->view('main_view');
> }
>
> function input()
> {
> $this->load->view('input_view');
> } } ?>
Upvotes: 2