I got this error message when i run my php CodeIgniter project:
A PHP Error was encountered
Severity: Warning
Message: Cannot modi
You can't display anything before the header function is called. You should not display anything form model or controller to avoid this kind of error. If you want to display something form the controller or model then you should store the output to the buffer instead of sending it to the browser. You can store the output to the buffer using ob_start()
function before header()
function is called. Then you can do something like this
if(true)
{
header("Location:http://google.com");
}
else
{
ob_end_flush();
}
I think it will be helpfull
Use $config['sess_save_path'] = sys_get_temp_dir();
instead of $config['sess_save_path'] = NULL;
in your Application/config/config.php
file
this was your issue - echo $row->members_id . ""; -- as the above answers say, don't echo something in your controllers, push to do it in the views - always
While using codeigniter, its best recommended that you echo
only in views.
Echoing anywhere randomly sends some data to browser, after which you can't modify headers (this includes attempt to redirect, set content-type, etc)
You should re-organize your code, such that, echo
are done within views only. This will solve your header issues in Codeigniter.
This also includes extra whitespaces at the end after the closing brace "} ?>
" in non-view php files.