Welcome Guest, Not a member yet? Register   Sign In
problems redirecting because of header
#1

[eluser]frist44[/eluser]
So I develop on my local machine and don't have problems with this. However, the following code in my controller is causing problems when uploaded to godaddy:

Code:
// If not username is provided, redirect to home
        if ($username === FALSE) redirect(base_url());
        
        if (!is_logged_in()) {
            $this->session->set_userdata('prev_url', cur_url());
            redirect_to_login();
        }
        
        // If username is the same as currently logged in user, redirec to user profile        
        if ($username == $this->session->userdata('username')) redirect(base_url() . 'user/profile');
                  
        if ( $userid = $this->users_model->get_userid_from_username($username) ){

            $data['requests'] = $this->requests_model->get_requests_by_user($userid);        
            $data['supplies'] = $this->supplies_model->get_supplies_summary_by_user($userid);
            $data['profile'] = $this->users_model->get_profile($userid);
            $data['content_view'] = 'user_info_view';
            $this->load->view('container_view', $data);            
            
        } else {
            redirect(base_url());
        }

This is the error:

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/users_model.php

Line Number: 160
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/content/d/a/t/databanks/html/system/libraries/Exceptions.php:166)

Filename: helpers/url_helper.php

Line Number: 539


How can I avoid these problems?
#2

[eluser]frist44[/eluser]
I figured it out. I had done something wrong.
#3

[eluser]enCODer[/eluser]
I have some simillar problem.

Code:
class Main extends Controller {

    function Main()
    {
        parent::Controller();
        $this->load->model('user_mod');
        $this->languages =  $this->session->userdata('lang');
        if ($this->languages == '' ) {
            $string = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
            list($language, $vaste) = explode(",", $string);
            $this->session->set_userdata('lang', 'lt');
        }
        $this->lang->load('main', $this->session->userdata('lang'));
    }


IE all versions shows me error on this:

Quote:A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 1

Filename: controllers/main.php

Line Number: 12

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at system/libraries/Exceptions.php:166)

Filename: libraries/Session.php

Line Number: 662

However, I do have some other function:
Code:
function set_language($lang) {
        $this->session->set_userdata('lang', $lang);
        redirect('index.php', 'refresh');
    }

And when I load it, I see all kinds of errors that shows „the headers were sent“. But i can not understand why it is only on IE because Chrome, Opera, Firefox do not show anything bad and it works just fine. Maybe there's a better way to solve this problem?
#4

[eluser]InsiteFX[/eluser]
If you have white spaces before or after the PHP tags you
will get the headers already sent error messages...

Enjoy
InsiteFX
#5

[eluser]enCODer[/eluser]
Yes, I do know this problem, so it was my first action to solve this, however, the problem haven't change. But is not there a problem when I am adding information to cookie on IE at my constructor and after that I just put different information on that session data again. Maybe this causes some problems in Internet Explorer, however as I can imagine this shouldn't be the case.

Finally, I managed to take a dofferent path on this, but I am still curious about this problem. Or maybe I did not erase those whitespaces right... Hm...
#6

[eluser]benjamin[/eluser]
You can always use ob_start()...




Theme © iAndrew 2016 - Forum software by © MyBB