I am trying to use a clicks counter script on my site but I got a header error:
Notice: Undefined variable: id in C:\public_html\RPG\includes\clicks.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\public_html\RPG\includes\clicks.php:3) in C:\public_html\RPG\includes\clicks.php on line 6
So i came here and read the sticky at the top of the forum, which says:
ive seen this error pop up time and time again, and the answer is ALWAYS the same. please look here before you post it. the problem is you are outputting to the browser (whitespace included) before sending a header. this is unallowed. remove output prior to the header, or use OUTPUT BUFFERING.
But i'm not sure how i could rearrange this as then it wouldn't run the query:
<?php include("dbconnect.php"); ?> <?php // clickcount is the table, with 2 columns: id and clicks $sql="UPDATE site SET clicks=clicks+1 WHERE (id = '$id')"; $result=mysql_query($sql,$dbcnx); $url = $_GET['url']; header("Location: http://$url"); /* Redirect browser to web site */ exit; // just to be nice ?>
Any help/advice would be great.