Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter doesn't load
#1

[eluser]Unknown[/eluser]
I started with codeIgniter today, and I'm following the beginner tutorial from phpacademy.
Right now i got an odd problem. i got the following very simple controller:

Code:
<?php if ( ! defined('BASEPATH')) exit("No direct script access allowed");

class Site extends CI_Controller {
public function index()
{
}

public function home()
{
  $this->load->view("view_home", $data);
}

function about()
{
  $data['title'] = "About!";
  $this->load->view("view_about", $data);
}

function test()
{
  echo "test";
}
}

It always loads the index function fine. When i test it, it echo's whatever i want it to echo. But when i call the other functions nothing happens.

I didn't setup my .htacces yet, but when i visit the following adress:
http://localhost:8899/index.php/site/home

it doesn't load the home function. same goes for the other function ("about" and "test");

When i call one of the functions ("home", "about" and "test") from within the index() function it does call it how it should:
Code:
class Site extends CI_Controller {
public function index()
{
            $this->home();
}

public function home()
{
  $this->load->view("view_home", $data);
}

I'm not quite sure what is going wrong here. Hopefully someone can guide me in the right direction!
#2

[eluser]Tpojka[/eluser]
Set constructor method too before all other methods and see what will happen:

Code:
public function __construct()
{
  parent::__construct();
}
#3

[eluser]InsiteFX[/eluser]
Try setting up a route to it.

Code:
$route['site/(:any)'] = 'site/$1';
#4

[eluser]Unknown[/eluser]
Thanks for the reply's! i found out the problem. For some reason screwed with the:
Code:
$config['uri_protocol

i had:

Code:
$config['uri_protocol'] = 'QUERY_STRING';

i has to be:
Code:
$config['uri_protocol'] = 'AUTO';


So this was the reason it wasn't calling my functions through the url's.




Theme © iAndrew 2016 - Forum software by © MyBB