-3

Possible Duplicate:
php headers already sent error

I have tried every thing to solve it, but this thig just wont go away.

Here is what I'm doing

if($query)
{
header("location:cool.php");
exit();
}

even though $query is executed, an issue with header.

thanks.

Community
  • 1
  • 1
steve
  • 31
  • 2
  • 8

3 Answers3

3

ANY output will need headers sent, so any output will get you this error.

Common problems:

  • whitespace (e.g. before the <?php )
  • errors / exceptions
  • debugging echos/var_dumps
  • warnings from php (deprecated)
Nanne
  • 64,065
  • 16
  • 119
  • 163
1

You will get that error of you have any (I mean ANY) output beforehand

Naftali
  • 144,921
  • 39
  • 244
  • 303
  • even with this?? echo mysqli_error($connect); – steve May 24 '11 at 19:17
  • @steve, do you have **ANYTHING** outputted to the page? – Naftali May 24 '11 at 19:17
  • 1
    yes, anything. any output. thats what the word **ANYTHING** means. it means anything – Naftali May 24 '11 at 19:19
  • Yes even with this it's possible. `echo mysqli_error($connect);` is not complete PHP code. Maybe you have a blank or carriage return right before the opening tag, for example: `_`. Or your code is included by other code and outputs s/t before including. etc. – Jürgen Thelen May 24 '11 at 19:20
  • @steve absolutely **ANY** output, e.g. any line of code starting with `echo` or any functions that might send output to the browser before your call to `header` will cause the error. – Brian Driscoll May 24 '11 at 19:20
0

Ensure that $query is not outputting any data, other wise you'll get your error.

If not check to make sure NO data is being output before hand.

DarkMantis
  • 1,510
  • 5
  • 19
  • 40