Welcome Guest, Not a member yet? Register   Sign In
weird bug in my app
#1

[eluser]Iwasignited[/eluser]
Hi all
Here is the code, please let me know what im doing wrong

controller:
Code:
function add_comment($entryID)
    {
        $is_logged_in = $this->is_logged_in();
        $user_id = $this->user_id();
        $this->load->model('entry_model');
        // If the user is not logged in yet, redirect him and send a message
        if(!isset($is_logged_in) || $is_logged_in != true)
        {
            $this->session->set_flashdata('msg', 'You have to login to add comment');
            redirect('site/index');    
            
        }        
        // A not real entry
        if (!$this->entry_model->getDetails($entryID))
        {
                $this->session->set_flashdata('msg', 'Not real entry');
                redirect('site/index');
        }
        // If ok, show the add comment page
        $data['main_content'] = 'add_comment';
        $data['user_id'] = $user_id;
        $data['entry_id'] = $entryID;
        $this->load->view('includes/template', $data);
    }

I receive this error when going to a not real entry
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\CMS\application\models\entry_model.php:190)

Filename: libraries/Session.php

Line Number: 662
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\CMS\application\models\entry_model.php:190)

Filename: helpers/url_helper.php

Line Number: 541


Please help me
#2

[eluser]Iwasignited[/eluser]
This error is encoutered by set flash data and redirect after loading the model
but I have to load it, anyone can help me?
#3

[eluser]Iwasignited[/eluser]
please anyone, I really need it
#4

[eluser]stef25[/eluser]
What is in models\entry_model.php line 190 ?

Also, I'm not sure if $is_logged_in != true is correct. Try $is_logged_in == FALSE or $is_logged_in !== TRUE

EDIT: Actually, your $this->load->view('includes/template', $data); should be in an else statement, so you can't get the redirect AND the load->view together. Even though you redirect, the code keeps running and tries to load a view. Maybe ... not sure.
#5

[eluser]Iwasignited[/eluser]
entry_model 190 is the end of the file
I tried $is_logged_in == FALSE but it still doesnt work
even when I comment out the rest of the fucntion after conditions, the errors r still there
#6

[eluser]kgill[/eluser]
Check your code for spaces or carriage returns at the end of the file after the ?> tag. Ideally you shouldn't have the php closing tag at all, see the user guide section for the style guide.

ps. 2 bumps in a little over an hour? It's the weekend man, have some patience. Tongue
#7

[eluser]Iwasignited[/eluser]
I deleted the closing tag and it works like a charm. Thank you a bunch Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB