I was trying to use a session based hit counter using the following code:
<?php
session_start();
mysql_connect ("localhost", "username", "password");
mysql_select_db (databasename);
if (!session_is_registered("counted")) {
mysql_query("UPDATE table SET count=(count +1) WHERE count_id=1");
session_registere("counted");
}
?>
I am getting "headers already sent by" errors.
The problem is that this code is in the same page as HTML code and everytime I try to put this php script at the very top of the page, when I save it , it moves the code back to the HTML body.
Any help would be greatly appreciated.
Thanks.