Welcome Guest, Not a member yet? Register   Sign In
Absolute beginner question - CI installation and reference
#1

[eluser]Unknown[/eluser]
Hi, I'm just learning CI and I'm trying to figure out why I can't get something very basic to work.

- I uploaded my unzipped CI folder structure to my web server.
- I get the welcome screen so I know it is working to some extent
- I want to create a new controller and access it via the URL http://mysite.com/index.php/newcontroller/

- My 'newcontroller' controller looks like this:
Code:
<?php
class Newcontroller extends Controller {

    function newcontroller()
    {
        parent::Controller();    
    }
    
    function index()
    {
        echo 'Hello World!';
    }
}
?>

I upload this, but when I try and access http://mysite.com/index.php/newcontroller/ I get a 404 page not found error.

I'm sure this is a simple thing, but I'm hoping someone can just give me some direction.

Thanks.
#2

[eluser]natefons[/eluser]
make sure the php file is called "newcontroller" and not any deviation of "NewController, newController" etc etc.
#3

[eluser]InsiteFX[/eluser]
Also make sure you set the default controller in application/config/routes.php

InsiteFX
#4

[eluser]cahva[/eluser]
Also the constructor should start also with uppercase:
Code:
function Newcontroller()

If you're on PHP5 server(and you should be), you might aswell use PHP5 style construcror:
Code:
function __construct()
{
    parent::__construct();
}




Theme © iAndrew 2016 - Forum software by © MyBB