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