The first line in my PHP document includes a file that sets some global variables and sets up my database connection. The include file looks like this:
<?php
global $host_root,$domain,$site_url,$db_host,$db_user,$db_password,$database;
(sets the variables here)
mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($database);
?>
The next statement includes a file with user login and logout functions.
I then check to see if the user is logged in, if they are not, I want to set a test cookie to be checked for on a subsequent page to see if they have cookies turned off or if they are actually just not logged in. However, for some reason, it is saying my global_vars.inc file is already printing header information: Here's what it looks like:
index.php has this at the very beginning before any HTML:
<?php
require_once("../includes/php/global_vars.inc");
require_once("../includes/html/header.php");
?>
header.php has this, before any HTML:
<?php
require_once("../includes/php/login_logout.inc");
// if not logged in set a test cookie to be able to check for cookies
if (!(user_isloggedin())) { setcookie('cookiecheck','on'); }
?>
Error I'm getting is:
Cannot add header information - headers already sent by (output started at /home/httpd/vhosts/mydomain/includes/php/global_vars.inc:14)
But global_vars.inc has no HTML or echo/print statements so what's up?!