L'header lo devi mandare prima di qualunque output...ad esempio quell'errore te lo può dare se fai una cosa del tipo

<html>
<head>
...
</head>
<?php
header("location:chatview.php")
?>
...