Welcome Guest, Not a member yet? Register   Sign In
Beginner issue: I can't get any controllers to work.
#1

[eluser]oddvalue[/eluser]
Hi.

I literally just started using CodeIgniter today so I'm really new to this.

I've been reading through all the documentation that comes with it and I've been trying to get the basic 'Hello World!' example to work but it just doesn't want to.

I can get the welcome page up no problem but the moment I start adding controllers after 'index.php' it just comes back with 'Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.'

Could I have missed something? Or is it possible some settings on my server are clashing?

Thanks for any suggestions.
#2

[eluser]InsiteFX[/eluser]
You need to change the default controller in apllication/config/routes.php

Enjoy
InsiteFX
#3

[eluser]oddvalue[/eluser]
Thanks for the quick reply but that didn't help. If I change the default controller to anything other than 'welcome' it stops working.
#4

[eluser]jedd[/eluser]
[quote author="oddvalue" date="1255741583"]
I can get the welcome page up no problem but the moment I start adding controllers after 'index.php' it just comes back with 'Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.'
[/quote]

index.php isn't a controller.

When you say 'adding controllers after index.php' - where are you putting these new controllers?

What are they called (directory and filename) and what are the contents (show us) and what are the URL's you're using to try to access them?
#5

[eluser]oddvalue[/eluser]
I've just been trying to follows the instructions here http://ellislab.com/codeigniter/user-gui...llers.html

I follow the instructions to the word and it doesn't work. Put a file called 'blog.php' in /application/controllers/ with the Blog class in it telling it to echo 'Hello World!' then direct my browser to http://[my_domain]/index.php/blog.

What am I missing?
#6

[eluser]jedd[/eluser]
[quote author="oddvalue" date="1255756501"]
I follow the instructions to the word and it doesn't work. Put a file called 'blog.php' in /application/controllers/ with the Blog class in it telling it to echo 'Hello World!' then direct my browser to http://[my_domain]/index.php/blog.
[/quote]

Sometimes people make a mistake with case, sometimes naming, sometimes something else that's not obvious to someone who's just starting out - that's why it's a good idea to cut-n-paste what you've put in the file. Use the [ code] tags when you post it, but there's plenty of space in a message to show us everything that you're doing.

What OS are you on? You say the filename is called blog.php - which is good, and should be fine on the three common platforms.

Are you using Apache? Try tracking the apache error and access logs - ideally you can do this in real time - if you're on a real operating system you can do this with these commands:
Code:
#  tail -f /var/log/apache2/access.log &
#  tail -f /var/log/apache2/error.log &
- you can run that in a terminal and watch the output as you try to load your page in your browser. If you're using a cruddy operating system, you'll have to find out how to get the same information.

You'll be looking for errors about files it can't find, or files it doesn't have permission to read. You can check your file permissions too, just to make sure - again, how you do this depends on your platform.

Did you make any changes to the other config files - such as changing the index_page in config.php? In that same file, what did you set your base_url to?
#7

[eluser]alboyd[/eluser]
Why don't you watch some video tutorials and follow along. I find this is very helpful when first starting out. I'm sure you will manage to find heaps online - but if you have any trouble I can point you in the right direction (my vids) Smile
#8

[eluser]oddvalue[/eluser]
Ok well I've done everything that this link tells me: http://ellislab.com/codeigniter/user-gui...llers.html

My code in 'blog.php' is as follows:
Code:
<?php
class Blog extends Controller {

    function index()
    {
        echo 'Hello World!';
    }
}
?>

Sadly I can't access any of the error logs. I'm hosting through a third party on a LAMP server. I could try it out on a local Linux server but I put all my sites on the same host so I figured it would be best to try it all out there.

Does it matter that it's on a subdomain?

The only config changes I've made have been to change the base_url to my url.

It all seems really simple and I can see what it's trying to do. I just can't seem to make it happen.
#9

[eluser]Tom Schlick[/eluser]
please paste the contents of your config.php file as well as the url you are trying to access.
#10

[eluser]oddvalue[/eluser]
The URL I'm trying to access is 'http://dev.oddvalue.co.uk/index.php/blog/' as per the example and this is my config file:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
*/
$config['base_url']    = "http://dev.oddvalue.co.uk/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'        Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'        Uses the REQUEST_URI
| 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol']    = "AUTO";

/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://ellislab.com/codeigniter/user-guide/general/urls.html
*/

$config['url_suffix'] = "";

/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language']    = "english";

/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = "UTF-8";

/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the "hooks" feature you must enable it by
| setting this variable to TRUE (boolean).  See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;


/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries.  For more information please see the user guide:
|
| http://ellislab.com/codeigniter/user-guide/general/core_classes.html
| http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';


/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify with a regular expression which characters are permitted
| within your URLs.  When someone tries to submit a URL with disallowed
| characters they will get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
I havn't included the whole thing because a) it's too long and b) the rest of the settings havn't been changed.




Theme © iAndrew 2016 - Forum software by © MyBB