1

Possible Duplicate:
Headers already sent by PHP

I finally got my first Mac Book yesterday. I like it , but one problem is really screwing with me . For some reason my project I transferred from my windows laptop isnt working properly. XAMPP starts up , I go to localhost/CI_BUHZ and the login page works as expected , I type in my credentials and hit enter, but then for some reason the whole thing gets stuck on my validate_credentials function in my login controller. it doesnt give me any errors , only 2 warnings - included below

Id like to note that: *This project works perfect on my old windows laptop i transferred it from. *Mod Rewrite is on to the best of my knowledge- if my my other controllers method calls such as CI_PROJECT/Login and CI_PROJECT/Feeds/Home are working right? *Even if i delete the validate_credentials function and recreate it with only this:

function validate_credentials()
    {  



    redirect('site/home');
    }

it still will not go from login -> site/home on my mac.

Here is the original validate credentials function :

function validate_credentials()
    {       
        $this->load->model('membership_model');
        $query = $this->membership_model->validate();
        if($query) // if the user's credentials validated...
        {
            $uid = $this->membership_model->grab_uid();
            $data = array(
                'username' => $this->input->post('username'),
                'uid' => $uid,
                'is_logged_in' => true
        );
        $this->session->set_userdata($data);
        redirect('site/home');
        }
        else // incorrect username or password
        {
            $this->index();
        }
    }   

here is the .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CI_BUHZ/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

Here's the img_model its complaining about ( even though the function being called doesn't require this model at all:

<?php

class Image_model extends CI_Model {


function get_images ($album_id, $uid){
    $album_id =(int)$album_id;
    $q = $this->db->query("SELECT image_id, album_id_fk, timestamp, ext, uid_fk FROM images WHERE album_id_fk = $album_id AND uid_fk = $uid");
        if($q->num_rows() > 0) {
            foreach($q->result() as $row) {
                $data[] = $row;
            }

            return $data;
        }
    }


function image_check($image_id , $uid_fk){
$image_id = (int)$image_id;
$query = mysql_query("SELECT COUNT(image_id) FROM images WHERE image_id = $image_id AND $uid_fk");
return (mysql_result($query, 0)==1) ? true : false;

}

function delete_image($uid_fk, $image_id){
$image_id =(int)$image_id;

$image_query = mysql_query("SELECT album_id_fk , ext , uid_fk FROM images WHERE image_id = $image_id AND uid_fk = $uid_fk");
$image_result = mysql_fetch_assoc($image_query);
$album_id = $image_result['album_id_fk'];
$ext = $image_result['ext'];
$uid = $image_result['uid_fk'];

unlink('uploads/'.$uid.'_'.$album_id.'_'.$image_id.'.'.$ext);
unlink('uploads/thumbs/'.$uid.'_'.$album_id.'_'.$image_id.'.'.$ext);

mysql_query("DELETE FROM images WHERE image_id = $image_id AND uid_fk = $uid_fk");


}
}

?>


A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/CI_BUHZ/application/models/image_model.php:2)
Filename: libraries/Session.php
Line Number: 672
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/CI_BUHZ/application/models/image_model.php:2)
Filename: helpers/url_helper.php
Line Number: 546
Community
  • 1
  • 1
ChuckKelly
  • 1,742
  • 5
  • 25
  • 54
  • K, I think an exception is being thrown somewhere and that is your output. I commented before how old your previous Windows setup was (e.g. newer version of PHP), put `error_reporting(0);` on top of the page and see if it does the trick .. – dbf Dec 24 '12 at 00:28
  • Whats the code of the lines `672 in libraries/Session.php` and `546 in helpers/url_helper.php`? – dbf Dec 24 '12 at 00:38
  • @dbf hiding an error does not fix it. Fix the issue rather than sweeping it under the rug as you are suggesting. – kittycat Dec 24 '12 at 00:40
  • @cryptic So where did I say "It will fix your problem when you hide the error"? .. please please please surprise me .. ;) – dbf Dec 24 '12 at 00:41
  • @dbf you're telling OP to essentially turn off error reporting so the error no longer appears. That's a band-aid fix. – kittycat Dec 24 '12 at 00:45
  • @cryptic yea, funny eh .. my next thing would have been to let him check the error_reporting settings on both environments, I guess I could have just said that instead .. do you like me still as I like you very much? – dbf Dec 24 '12 at 00:49

1 Answers1

0

Make sure that nothing is outputted before you modify headers.

One very common reason for this error message is that there are newlines or other text after the closing PHP ?> tag. If there is only PHP in the file it is best not to use ?> at all (it is not mandatory, and not necessary either).

Sverri M. Olsen
  • 13,055
  • 3
  • 36
  • 52