How to fix headers sent error on PHP

Check were is the problem. Put this code before session_start().

if (headers_sent($file, $line)) {
    die("Headers already sent in $file on line $line");
}