Responsive Ad Slot

Tech

PHOTOGRAPHY

Games

Tech

Warning: Cannot modify header information - headers already sent by - SOLVED

Sunday, 15 February 2015

 

Echo before header

<?php
echo "hello world"
...
header('Location: http://...');
?>


Solution:

RemoveRemove the echo before header
Use ob_start(); and ob_end_flush(); for buffered output 


New-line characters or spaces before <?php


       <?php
... header('Location: http://...');
?>


Solution:

Remove everything before <?php

BOM (Byte-Order-Mark ) in utf-8 encoded php files


 <?php
...
header('Location: http://...');
?>


Solution:

Change the file encoding to "without BOM" (e.g. using notepad++) or remove the BOM before <?php using a HEX editor


Header Location in mixed php/HTML

<html>
...
<body>
...
<?php header('Location: http://...'); >
...
</body>
</html>

Sorry, you cannot use header-location here, because the header and the HTML code have already been sent!

Empty lines, chars or spaces after ?> when using an php include file

<?php
...
?>

...
...



Solution:

Remove everything after ?> in the php include file

Latest

Blog Archive

Hit Me