PHP header: url_helper has failed me.

I guess this is a 3-part post so i don't end up polluting the forums...

1) Alrighty. Let me get started on the right foot here by saying hi to everyone. I'm a New CI guy here ( >1 week) and have been loving every minute of it...until

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at CodeIgniter\system\application\controllers\home.php:8)

Filename: helpers/url_helper.php

Line Number: 487

dun dun dun...
the funny thing is the $echo (on line 8 below) prints fine, and then the error follows.

Quote:let me preface the situation :
I'm using FreakAuth Light (which is the topic of the second question) and the logins work alright and maybe that has something to do with all this?

so i investigated:

2class Home extends Controller    {
5    function Home()    {
6        parent::Controller();
7        $this->load->helper('url');
8        echo 'how is this possible?!';
        if(isValidUser()) {

    function index() {
    if (isValidUser()) {
        $data['username'] = $this->db_session->userdata('user_name');
        $data['user_id'] = $this->db_session->userdata('id');

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

and \CodeIgniter\system\helpers\url_helper.php
469 /**
     * Header Redirect
     * Header redirect in two flavors
     * @access    public
     * @param    string    the URL
     * @param    string    the method: location or redirect
     * @return    string
479     if (! function_exists('redirect'))
    function redirect($uri = '', $method = 'location')
            case 'refresh'    : header("Refresh:0;url=".site_url($uri));
487            default            : header("Location: ".site_url($uri));
492  }

so all I did was use the usual redirect() in my controller...what did i do wrong??
all I'm trying to do is write out a redirect that basically goes
if you're logged in
   you're going to /home/
}but if you're not{
   take a look at our schnazzy welcome page. go sign up there. its good for you.

second question:
I'm loving that there are so many different libraries that extend the capabilities of CI. But in my dabbling i've found that FreakAuth works better than the BackendPro library also available. Does anyone have a suggestion over which library would work for a site that would have to accommodate many many users.

second.5 question:
why isn't there a resource for libraries like FreakAuth and such that have just a listing of its functions and what each does and returns? I haven't found anything like that on FreakAuth and barely have found something for CI...unless i've been missing something all this time.

third question:
has anyone here completed a user-driven site using the CI framework? all i've been seeing are blogs and personal sites. I haven't yet seen a site where groups of people generate the content, as opposed to the CI coder who owns the site. just wondering.

thanks, again to anyone who has taken the time to read this, and even lend a helping hand...or at least a pointed finger in the right direction. I'm eager to learn CI, and I know learning it will take me a long way.


The problem will be probably an extra space or line somewhere in your files. One way to prevent this is not using the end php bracket. If you were debugging and you output something to the page it's possible this is the problem.

For your third question. Isn't a cms an example of a user created content site Smile Most people who ask questions are starting with CI or even with php and it's understandable people are not going to start with a complex website.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.