Forum Moderators: coopster

Message Too Old, No Replies

Phrase for every 10 visits

         

Dexie

10:10 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



Hi Coopster and Jatar,

Hope you're both still around ;-)

I've been getting a bit stuck on this one, which page does this go on? and where would it go on the page please?

Try reformatting your php code and see what happens, like so

<?php $counterfile = 'counter.txt'; $phrasesfile = 'phrases.txt'; $multiple = 10; // Read in the value, trim off any newlines, and // convert it to an integer, // just in case: $text = intval(trim(@file_get_contents($counterfile))); // Update the file with the old value plus this hit: @file_put_contents($counterfile, $text += 1); // Is the value a multiple of 10? if ($text && $text % $multiple == 0) { // Read the phrases file into an array: $file = @file($phrasesfile); print 'Hey! It\'s visit #' . $text . '!<br />'; // Grab a random phrase from the file read in as an array: print $file[rand(0, count($file) - 1)] . '<br />'; }?>

coopster

12:56 am on Jun 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you referring to this thread?

Phrase for every 10 visits [webmasterworld.com]