I want to track hits to specific pages on my site. I set up the database with names. count_id and count. I can't seem to get it to work. Any ideas? Thanks.
Here is what I have:
<?

mysql_connect("localhost","name","pass");

mysql_select_db("TrackPlays");

session_start();

$myValue = "A";

$result = mysql_query("SELECT count_id FROM simplecount WHERE name like '$myValue%' ");

while($r=mysql_fetch_array($result))
{

$count=$r["count_id"];

if (!session_is_registered("counted")){
mysql_query("UPDATE simplecount SET count=(count + 1) WHERE count_id='$count'");
session_register("counted");
}

?>

    I'd first ask the host if the already have logging in place, and if not why not.

      session_start() should go at beginning of script.

      Also where have you registered the session?

      Perform error checking e.g. mysql_select_db("TrackPlays") or die(mysql_error());

        I tried putting session_start at the beginning. Still no results. The database will update if I use this code:
        <?

        mysql_connect("localhost","name","pass");

        mysql_select_db("TrackPlays");
        session_start();
        if (!session_is_registered("counted")){
        mysql_query("UPDATE simplecount SET count=(count + 1) WHERE count_id=1");
        session_register("counted");
        }
        ?>

        But not the code I first provided. Can you figure out why? Thanks for your help.

          I got it. Thanks for all the help. Jamie.

            Write a Reply...