So I have this script to build cookies. Problem is that whenever I run the script it keeps telling me that I have already sent the headers. I am not sure when or where they get sent. Any help
Here is the script I run
include("include_files.php");
$link = mysql_connect("localhost", "dblankenbuhler", "schoolreiji");
mysql_select_db("wpdb", $link);
if($_POST["give"])
{
$res = mysql_fetch_array(mysql_query("SELECT * FROM customers WHERE id = ".$_POST["id"]), MYSQL_ASSOC);
$cust = buildObjectFromResult($res, "Customer");
setcookie("student", $cust->id, 0, "/");
}//end if
else if($_POST["remove"])
{
$res = mysql_fetch_array(mysql_query("SELECT * FROM customers WHERE id = ".$_POST["id"]), MYSQL_ASSOC);
$cust = buildObjectFromResult($res, "Customer");
setcookie("student", $cust->id, time()-60, "/");
}//end else if
else if($_GET["item_key"])
{
setcookie($_GET["item_key"], 0, time()-60, "/");
}//end else if
header("Location:".$_SERVER["HTTP_REFERER"]);
Here is the error I get:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/repo_code/include_files.php:9) in /var/www/repo_code/buildcookiethenreturn.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at /var/www/repo_code/include_files.php:9) in /var/www/repo_code/buildcookiethenreturn.php on line 23
Here is the script called include_files:
include("mysqlbuilder.php");
include("utilityfunctions.php");
function __autoload($class)
{
include_once("object/$class.php");
}//end __autoload
The two files included in that script are just a bunch of functions