Link to home
Start Free TrialLog in
Avatar of nooch44
nooch44

asked on

having trouble with a flash hit counter

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

Avatar of Emad Gawai
Emad Gawai
Flag of United Arab Emirates image

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

ASKER CERTIFIED SOLUTION
Avatar of Emad Gawai
Emad Gawai
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial