# Live PHP and flash hit coutner

**URL:** https://forum.kirupa.com/t/live-php-and-flash-hit-coutner/214410
**Category:** Uncategorized
**Created:** [January 28, 2007, 7:59pm UTC](https://forum.kirupa.com/t/live-php-and-flash-hit-coutner/214410 "2007-01-28T19:59:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![cybervanes](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@cybervanes](https://forum.kirupa.com/u/cybervanes)
#### Post date: [January 28, 2007, 7:59pm UTC](https://forum.kirupa.com/t/live-php-and-flash-hit-coutner/214410/1 "2007-01-28T19:59:38Z")

</div>

Hello Everyone,

I’m using flash 8 and action script2.0 to build this application.

I’m trying to compile a page hit counter that is only activated when the timeline hits a certain position. I thought I had it with the following script…. But the count would randomly get reset back to zero. I tried everything to debug the issue but it happened so randomly that I could not figure it out.  
Here is the PHP script:

PHP Code:  
[LEFT][COLOR=#000000][COLOR=#0000bb]\<?php  
[/COLOR][COLOR=#ff8000]//Reading the file  
[/COLOR][COLOR=#0000bb]$count [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]file\_get\_contents[/COLOR]COLOR=#007700;  
[/COLOR][COLOR=#ff8000]//Increasing the count  
[/COLOR][COLOR=#0000bb]$count [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]explode[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"="[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$count[/COLOR][COLOR=#007700]);  
[/COLOR][COLOR=#0000bb]$count[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]] = [/COLOR][COLOR=#0000bb]$count[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]]+[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700];  
[/COLOR][COLOR=#ff8000]//Writing to file  
[/COLOR][COLOR=#0000bb]$file [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]fopen[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]“main\_counter.txt”[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]“w+”[/COLOR][COLOR=#007700]);  
[/COLOR][COLOR=#0000bb]fwrite[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$file[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]“count=”[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]$count[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]]);  
[/COLOR][COLOR=#0000bb]fclose[/COLOR]COLOR=#007700;  
[/COLOR][COLOR=#ff8000]//Returning the count  
[/COLOR][COLOR=#007700]print [/COLOR][COLOR=#dd0000]“count=”[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]$count[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]];  
[/COLOR][COLOR=#0000bb]?\>[/COLOR] [/COLOR][/LEFT]

With this attempt I used the “loadVaribales” method to communicate with the PHP and TEXT files.

Here is the code in the first frame of the time line:

Code:  
[LEFT]this.loadVariables(“counters/main\_counter.txt?num=”+random(999999));[/LEFT]

Here is the code in the second frame:

Code:  
[LEFT]this.loadVariables(“counters/main\_counter.php?num=”+random(999999));[/LEFT]

It works awesome for a few weeks then the count gets reset to zero. So if anybody has an idea why the contents of the text file are randomly getting deleted, please let me know. I would be happy to email the source files.

Thanks in advance to all
