Counter grr's

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dorign
    Member
    • Jul 2004
    • 48
    • 3.6.x

    Counter grr's

    I seem to have a problem with counters and I never know why.

    Using this code,

    Code:
    <?php
     if (file_exists('count_file.txt')) 
     {
      $fil = fopen('count_file.txt', r);
      $dat = fread($fil, filesize('count_file.txt')); 
      echo $dat+1;
      fclose($fil);
      $fil = fopen('count_file.txt', w);
      fwrite($fil, $dat+1);
     }
     else
     {
      $fil = fopen('count_file.txt', w);
      fwrite($fil, 1);
      echo '1';
      fclose($fil);
     }
    ?>
    For some reason, it starts over (randomly, seemingly).. can anyone please help me out with a good, basic text script that's reliable?

    Thanks!
    www.ev0lnetwork.net
    Where the big kids post.
  • Dorign
    Member
    • Jul 2004
    • 48
    • 3.6.x

    #2
    Bump
    www.ev0lnetwork.net
    Where the big kids post.

    Comment

    • Dorign
      Member
      • Jul 2004
      • 48
      • 3.6.x

      #3
      It'd be awesome if someone could show me how to convert the above code into one that writes to a DB instead of a file.
      www.ev0lnetwork.net
      Where the big kids post.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...