Welcome Guest, Not a member yet? Register   Sign In
headers sent by model
#1

[eluser]Thorpe Obazee[/eluser]
Quote:Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\tuts\apps\models\comment_model.php:1)

I am having a problem with my project and this is because the this error. I posted the model in question but I still don't see the problem.

Code:
<?php
class Comment_model extends Model
{
    function __construct()
    {
        parent::Model();
    }
    
    function save()
    {
        $db_array = array
        (
            'user_id'        => $this->user_id,
            'tutorial_id'    => $this->tutorial_id,
            'comment_message'=> $this->comment_message
        );
        
        $this->db->insert('comments',$db_array);
        
        $this->db->set('comment_count', 'comment_count + 1', FALSE);
        $this->db->where ('id', $this->tutorial_id);
        $this->db->update('tutorials');
    }
    
    function view()
    {
        $this->db->select('users.user, comments.comment_message, comments.comment_posted, comments.id as comment_id');
        $this->db->from('comments');
        $this->db->join('users', 'users.id = comments.user_id');
        
        $this->db->where('tutorial_id', $this->tutorial_id);
        
        return $this->db->get();
    }
}

?>
#2

[eluser]xwero[/eluser]
Check if there are no spaces in front <?php or after ?>. It's best to remove the ?> all together.
#3

[eluser]Thorpe Obazee[/eluser]
Errmm.. it still doesn't work..

There's just something about that model that when I remove it, everything works fine but when I add it problem occurs on some methods.
#4

[eluser]Thorpe Obazee[/eluser]
What I did is, I completely removed that model and put it's methods in the bigger model. Everything works now :|

I sure wish I knew what was wrong...
#5

[eluser]nmweb[/eluser]
Maybe your editor is screwing things up. It's something to do with spaces or other characters not between <?php and ?>
#6

[eluser]Thorpe Obazee[/eluser]
[quote author="nmweb" date="1211890828"]Maybe your editor is screwing things up. It's something to do with spaces or other characters not between <?php and ?>[/quote]

I was thinking about that too. Btw, I was using notepad++

I don't know if anyone had issues like that with the particular editor.
#7

[eluser]xwero[/eluser]
That is strange. There is nothing wrong with the model, maybe there is some error that doesn't get displayed but has some output.
#8

[eluser]Thorpe Obazee[/eluser]
Yep. I also see nothing wrong with it. Thanks anyway ^_^




Theme © iAndrew 2016 - Forum software by © MyBB