A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: how 2 create statistics, flash/php

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    66

    Post

    I want to keep score of how many times a button gets pressed in my site. I think it should be possible to send data to php file whenever its pressed. PHP should add 1 (hit) for that button. Trouble is I'm no hero in scripting.

    Anybody out there who can help me out with this?

    The purpose is to create somekind of statistics on how many times the button is pressed.


    Tnx!

  2. #2
    __OSX powered__ nucleuz's Avatar
    Join Date
    Aug 2000
    Location
    Norway
    Posts
    836
    you need two files:
    1. counter.txt -> put a 0 in it
    2. counter.php :
    Code:
    <?php
    $file = "counter.txt";
    $fp = fopen($file, "r");
    $cnt = fread($fp, 1024);
    $cnt++;
    fclose($fp);
    $fp = fopen($file, "w");
    fputs($fp, $cnt);
    fclose($fp);
    ?>
    Now: call this each time you click your button and you should see the number increase.

  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    66
    mmm doesent seem to work:

    I call it in flash using:

    Code:
    on (release) {
        loadVariablesNum("counter.php", 0, "POST");
    }
    is this correct?

  4. #4
    __OSX powered__ nucleuz's Avatar
    Join Date
    Aug 2000
    Location
    Norway
    Posts
    836
    Well, it works for me, do you have the counter.txt with a 0 in it???
    Does http://localhost/counter.php give you any warnings?? You might have to chmod the counter.txt file to get it running.

  5. #5
    Member
    Join Date
    Jan 2001
    Posts
    66
    it works! thumbs up

    ideed had to chmod the txtfile, chmodded the dir, thuoght that was enough. But it works great now!

    Thanks a lot!

  6. #6
    they call me the_jump... le_saut's Avatar
    Join Date
    Mar 2001
    Posts
    536
    CHMOD 755 counter.txt


    Remember your server could get mighty slow if users are continually sending info to a file.
    Also contents of txt files are able to be viewed in a browser much better to give the file a .php extension.

    James

  7. #7
    __OSX powered__ nucleuz's Avatar
    Join Date
    Aug 2000
    Location
    Norway
    Posts
    836
    But then again a .php file with just the 0 in will show up as well......
    Anyway; glad you got it going.

  8. #8
    they call me the_jump... le_saut's Avatar
    Join Date
    Mar 2001
    Posts
    536
    correct, hmmmm.
    I guess it's just a number and can't be related to anything.

  9. #9
    __OSX powered__ nucleuz's Avatar
    Join Date
    Aug 2000
    Location
    Norway
    Posts
    836
    But if you are paranoid ,in this case it is a number: who would?? But later on it could be something else:
    Code:
    <?php
    $file = "/dir/not/available/via/www/easy_counter.txt";
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center