Jump to content


Header issue...

  • Please log in to reply
1 reply to this topic

#1 mhoctober

  • Members
  • PipPip
  • Member
  • 15 posts

Posted 18 August 2006 - 09:59 PM


I want to check for the existence of a cookie, and if its not set, set it.

I am getting this warning as I load my code in a browser...any ideas??

Warning: Cannot modify header information - headers already sent by (output started at /home2/seeasale/public_html/updatestats.php:4) in /home2/seeasale/public_html/updatestats.php on line 14

Page Loads : 15

Here is the code...



if (isset($_COOKIE["ck"]))
//echo "Cookie Set";
//echo "Cookie Not Set, Setting Cookie and Updating Counter";

//Line 14 follows...
setcookie ("ckBeenHere", time()+43200); // will expire in 12 hours
$pageVisited =  $_SERVER['PHP_SELF'];

$dbh=mysql_connect ("localhost", "****", "****") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("seeasale_db"); 

$query="SELECT * FROM tblCounter where fldURL='$pageVisited'";
$result=mysql_query($query)or die (mysql_error());

if ($num==0) // page has never been visited before by anyone!

$query = "INSERT INTO tblCounter(fldURL,fldCount) VALUES ('$pageVisited',1)";
mysql_query($query) or die('There is a problem: ' .mysql_error());

$query = "UPDATE tblCounter SET fldCount = '$upCounterByOne'WHERE fldURL='$pageVisited'";
$result=mysql_query($query)or die (mysql_error());
echo "<center>";
Echo "Page Loads : ";
echo $upCounterByOne;


#2 corbin

  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 18 August 2006 - 10:01 PM

There cant be anything before headers.. So move the html and body tags till after the cookie stuff :D
Why doesn't anyone ever say hi, hey, or whad up world?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users