Solved

having trouble with a flash hit counter

Posted on 2009-03-30
2
271 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 30
How to validate 2 forms at once 8 27
function to display dynamic data in dropdown 8 28
PHP json decode 9 20
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now