0

I have a peculiar problem after having changed host: what was working on the other side now just says the following:

**Cannot modify header information - headers already sent by (output started at ect/etc/blah/database_config_file.php:1).

I have no idea of how could I be sending the headers in the database config file, and even checked it. There's nothing wrong with it (no spaces, no echo function). Any clues on how to fix this? It's a nightmare...

EDIT: I've read "headers already sent" but unfortunately it isn't helping me, together with many other discussions about this issue. Thanks for pointing that out. The thing I am trying to use is Abraham William's callback.php in Twitteroauth (works!). The database config is what gives the error (reportedly) and I can report it here if you want...There are no spaces. Besides, the same config file works fine if included in another PHP file. The issue is given, as far as I can see, by starting the session, checking if the given session is what you want, and then redirecting with header("location: somepage.php");, which, to me at least, is the normal authentication procedure. If you echo JavaScript instead of redirecting with PHP, it gives no error but there's no session stored either. I'm calling this a bug, because it's impossible to work this way.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
tattvamasi
  • 845
  • 1
  • 7
  • 14
  • At line #1 (and there's not any displayed characters before the ` – Mark Baker Nov 23 '13 at 18:41
  • 3
    Cookies, BOM (byte order mark), etc. count as output. Could also be caused by an included file. The possibilities are almost endless. – Funk Forty Niner Nov 23 '13 at 18:45
  • thanks for voting to close this thread even if I've already read Headers already sent and it's not helping me, btw. – tattvamasi Nov 23 '13 at 18:46
  • I've edited the question. The thing giving error is Abraham William's callback.php in Twitteroauth (I swear it works I have used it for years), with the inclusion of a simple file for DB credentials that has nothing in it except credentials...I have no idea. It shouldn't do that. – tattvamasi Nov 23 '13 at 18:52
  • 1
    @Fred-ii- `BOM` is a common reason, yes. But how should cookies be the reason? – hek2mgl Nov 23 '13 at 18:54
  • I don't use cookies...Well I start the session (and that's a cookie too), but checking if the session is there already doesn't seem to resolve the issue. I've checked all files for extra spaces and see nothing, maybe the error is given by `header("Location:example.php");` after having started the session? Totally no idea :( – tattvamasi Nov 23 '13 at 18:58
  • 1
    The error message is very precise: `output started at ect/etc/blah/database_config_file.php:1` means that the output was sent at line 1 (`:1`) of the `database_config_file.php` script file... if there's no visible content at line ` of that file before ` – Mark Baker Nov 23 '13 at 19:00
  • thanks. Well we'll never know because I couldn't fix it, got tired, bugged the host, and got the buffer. Case closed (?). I found a discussion on SO that says that godaddy does strange things with sessions but I don't know if it's the case here. Should you want me to delete the question I'll delete it no prob. – tattvamasi Nov 23 '13 at 22:27
  • See [**this answer on SO**](http://stackoverflow.com/a/8028987/1415724) under `setcookie / setrawcookie` @hek2mgl – Funk Forty Niner Dec 12 '13 at 15:12

0 Answers0