Solved

having trouble with a flash hit counter

Posted on 2009-03-30
2
278 Views
Last Modified: 2013-12-12
hello,
i have a .swf file with 4 (red, blue, yellow, green) buttons. each time a button is clicked it sends a var to a php file which writes it to a .txt file. it works, but not the way i need it to work. it wont work with multiple clicks on a given button. if you click the red button 3 times it only registers once, you have to refresh the page and click again for it to register another click. i need it to register clicks without refreshing...is this possible?
//ACTIONSCRIPT FOR THE BUTTON
 
_global.increaseTally = Number(1);
 
_root.bt1.onPress = function(){
loadVariablesNum ("TALLY.php?count=" + _global.increaseTally , 0);
}
 
//TALLY.php
<?php
if (file_exists('total.txt')){
	$fil = fopen('total.txt', r);
	$dat = fread($fil, filesize('total.txt'));
	fclose($fil);
	$fil = fopen('total.txt', w);
	fwrite($fil, $dat+$count);
	}
	else{
	$fil = fopen('total.txt', w);
	fwrite($fil, $count);
	fclose($fil);
	}
?>

Open in new window

0
Comment
Question by:nooch44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 20

Expert Comment

by:Gawai
ID: 24022246
are u adding file size to the number of count ?

$dat = fread($fil, filesize('total.txt'));

fwrite($fil, $dat+$count);
$fp = fopen('data.txt', 'w');
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);
 
if (file_exists('total.txt')){
        $fil = fopen('total.txt', 'a') or die("can't open file");
        fwrite($fil, $count);
        fclose($fil);
}
else {
        $fil = fopen('total.txt', w);
        fwrite($fil, $count);
        fclose($fil);
}

Open in new window

0
 
LVL 20

Accepted Solution

by:
Gawai earned 500 total points
ID: 24022254
sorry this one u can try

if (file_exists('total.txt')){
        $fil = fopen('total.txt', 'a') or die("can't open file");
        fwrite($fil, $count);
        fclose($fil);
}
else {
        $fil = fopen('total.txt', w);
        fwrite($fil, $count);
        fclose($fil);
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question