0

i was do some project, i move some php file into application/views when i try to call "localhost/siak/application/views/tabel-lookup.php" it went blank white page

after i check the view page source there's error "Uncaught Error: Call to undefined function base_url" on "" rel="stylesheet" />"

i was already set the config and everything in the back so i dont know what's the problemhere's the warning said

2
  • 1
    why are you trying to call view file thru URL? "localhost/siak/application/views/tabel-lookup.php" does not seems to be a valid CI URL Commented Jun 3, 2021 at 5:21
  • i set that on side-menu, the menu "tabel-lookup" i set with that url so it'll open on views file Commented Jun 3, 2021 at 5:32

1 Answer 1

0

If you're using CodeIgniter 3, you'll have to include the helper for this function to work. Here's how to enable it for the whole site:

In the file application/config/autoload.php, add 'url' to the list of helpers:

$autoload['helper'] = array('url');

To enable it on a page by page basis, put this in the constructor function of your controller - or at the very least, at the top of the page you're using.

$this->load->helper('url');

Also (sorry if you already know this), with CodeIgniter, you know you should access views through the controller, not directly. For example, in a codeigniter app, www.example.com/admin/users.php would route to a controller file called 'admin' and in that controller there would be a function called 'users' which would load a view like this $this->load->view('some_directory/users', $data);

Sign up to request clarification or add additional context in comments.

8 Comments

in my controller, i set $this->load->view("Dashboard"); does it mean the CI program would only read the Dashboard file url?
No, it means that it will load a view in your views folder called 'Dashboard.php'.
anyway, i also already set the helper in controller file.. but it keep giving me fatal error
What version of CodeIgniter are you using? What is the fatal error?
CI 3, the error was " fatal error, uncaught error call to undefined function base_url() "
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.