user2621440
user2621440

Reputation: 31

Unable to load the requested file error in codeigniter

I am new to CodeIgniter. I am getting this problem.

Unable to load the requested file:
http://localhost/grf_new/index.php/reservation/details/34/.php

the code looks like this

$this->load->view(base_url().index_page().'/reservation/details/'.$userid.'/', $data);

Upvotes: 3

Views: 34604

Answers (3)

Xavier W.
Xavier W.

Reputation: 1360

This should work (doesnt test) :

$this->load->view('reservation/details/'.$userid, $data);

Upvotes: 1

Sundar
Sundar

Reputation: 4630

Don't add base_url()

Load files using this

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

create a file in view folder if your folder like this

application/views

test/test.php

//---------------------

//If you want to read the URL use file_get_contents() function

Upvotes: 2

Bora
Bora

Reputation: 10717

Codeigniter Documentation: http://ellislab.com/codeigniter/user-guide/general/views.html

Loading a View

To load a particular view file you will use the following function:

$this->load->view('viewfile', $yourdata);

Where viewfile is the name of your view file. Note: The .php file extension does not need to be specified unless you use something other than .php.

Now, open the controller file you made earlier called blog.php, and replace the echo statement with the view loading function:

<?php
class Reservation extends CI_Controller {

    function details($id)
    {
        $this->data['user_info'] = $this->user_model->getUser($id)->result();
        $this->load->view('userdetails', $this->data);
    }
}
?>

If you visit your site using the URL you did earlier you should see your new view. The URL was similar to this:

example.com/reservation/details/34

Upvotes: 3

Related Questions