I'm confused about how output buffering works with the PHP header function.
Here is my code:
session_start();
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
require_once ($_SERVER['DOCUMENT_ROOT'] . '/classes/database.php');
require_once ($_SERVER['DOCUMENT_ROOT'] . '/classes/functions.php');
$db = new Database();
$db->open_connection(); // to database
$query = 'SELECT * FROM english WHERE id = ' . mysql_real_escape_string($_GET['dealerID']);
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
ob_start();
ob_flush();
header('http://www.domain.com/channel-partners/en/index.php?dealerID=' . $row['id'] . '&location=' . $row['location_url'] . '&name=' . $row['name_url']);
ob_end_flush();
This doesn't work. I get the "headers already sent" error. I know that I can't have any output before I call the header command, but I thought if I used ob_start() I could have output before the command is called. Obviously I am mistaken, but I don't know how to rectify this code so that I can have the session_start() where it needs to be, open a connection to my database and then call the redirect. Can someone help out? Thanks.