Jump to content

Counter script not working


adamriley

Recommended Posts

Hi could any one say why this is not working it is a counter script it does work with short start php (<?    ?>) but seems not to want to work with (<?php    ?>)

 

Entry.php (used to display the results)

<?php include("counter_plus.php"); ?>

<strong>Total Hits</strong><br />
<?php $total ?><br /><br />
<strong>Unique Hits</strong><br />
<?php $total_uniques ?>

 

counter_plus.php (main functions of the script)

<?php
$visits_file = "visits_plus.txt";
$uniques_file = "uniques_plus.txt";

// Change the following number to change which style of counter you want
// 1 is Regular font
// 2 is Digital font
// 3 is Alternate Digital font

$type = "1";

$counter = fopen($visits_file, "r");
$total = fread($counter, filesize($visits_file));
fclose($counter);
$total++;
$counter = fopen($visits_file, "w");
fwrite($counter, $total);
fclose($counter);

$unique_hits = fopen($uniques_file, "r");
$total_uniques = fread($unique_hits, filesize($uniques_file));
if($_COOKIE["plus_unique"] != "set") {
setcookie("plus_unique", "set", time()+2419200);
$total_uniques++;
}
$uniques_hits = fopen($uniques_file, "w");
fwrite($uniques_hits, $total_uniques);
fclose($uniques_hits);

if($type == "2") $digital = "_digital";
if($type == "3") $digital = "_digital_alt";

$total_numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$total_images = array("<img alt=\"0\" src=\"number_images/0$digital.png\" title=\"0\" />", "<img alt=\"1\" src=\"number_images/1$digital.png\" title=\"1\" />", "<img alt=\"2\" src=\"number_images/2$digital.png\" title=\"2\" />", "<img alt=\"3\" src=\"number_images/3$digital.png\" title=\"3\" />", "<img alt=\"4\" src=\"number_images/4$digital.png\" title=\"4\" />", "<img alt=\"5\" src=\"number_images/5$digital.png\" title=\"5\" />", "<img alt=\"6\" src=\"number_images/6$digital.png\" title=\"6\" />", "<img alt=\"7\" src=\"number_images/7$digital.png\" title=\"7\" />", "<img alt=\"8\" src=\"number_images/8$digital.png\" title=\"8\" />", "<img alt=\"9\" src=\"number_images/9$digital.png\" title=\"9\" />");

$total = str_replace($total_numbers, $total_images, $total);

$total_uniques_numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$total_uniques_images = array("<img alt=\"0\" src=\"number_images/0$digital.png\" title=\"0\" />", "<img alt=\"1\" src=\"number_images/1$digital.png\" title=\"1\" />", "<img alt=\"2\" src=\"number_images/2$digital.png\" title=\"2\" />", "<img alt=\"3\" src=\"number_images/3$digital.png\" title=\"3\" />", "<img alt=\"4\" src=\"number_images/4$digital.png\" title=\"4\" />", "<img alt=\"5\" src=\"number_images/5$digital.png\" title=\"5\" />", "<img alt=\"6\" src=\"number_images/6$digital.png\" title=\"6\" />", "<img alt=\"7\" src=\"number_images/7$digital.png\" title=\"7\" />", "<img alt=\"8\" src=\"number_images/8$digital.png\" title=\"8\" />", "<img alt=\"9\" src=\"number_images/9$digital.png\" title=\"9\" />");

$total_uniques = str_replace($total_uniques_numbers, $total_uniques_images, $total_uniques);
?>

 

Link to comment
Share on other sites

<strong>Total Hits</strong><br />
<?php $total ?><br /><br />
<strong>Unique Hits</strong><br />
<?php $total_unique ?>

 

Are you trying to DISPLAY the Total Hits and Unique Hits?  If so then you need put the echo in there-

<strong>Total Hits</strong><br />
<?php echo $total; ?><br /><br />
<strong>Unique Hits</strong><br />
<?php echo $total_uniques; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.