Possible Duplicate:
Headers already sent by PHP
I am trying to write a JSON API for an app that I am making. It's in PHP. At the beginning of the PHP script I try to check if all the GET parameters are present, if not, then the server should send a 400 - Bad Request header.
the code looks like this:
//CHECK CONDITIONS
if (isset($GET["clat"]) && isset($GET["clng"]) && isset($GET["limit"]))
{
//do stuff
} else {
header( "HTTP/1.0 400 Bad Request");
exit;
}
The server simply serves an empty page with the 200 - OK header. So I tested it on another webserver and there it does seem to work.
So apparently there's something wrong with the server. How do I go around debugging this issue?
EDIT
I seem to have found the line causing the header to always be 200-OK. At the beginning of the PHP I include another php file with some mySQL Connection parameters. When I comment out the include 'setup.php';
line it works. the setup.php contains the following:
// Connects to Our Database
mysql_connect("#####", "#####", "######") or die(mysql_error());
mysql_select_db("####") or die(mysql_error());
How do I remain the external DB info include while being able to send a different HTTP Header afterwards?
Thanks in advance.