iGuest 3 Report post Posted March 8, 2005 A Simple hit counter1.) Open your website in Notepad or watever u use .. and where you want the counter to be put in this code: <?php= "count.dat";if(!(Resource id #4 = fopen(,"r"))) die ("cannot open counter file");= (int) fread(Resource id #4, 20);fclose(Resource id #4);++;echo "Hits: ";Resource id #4 = fopen(, "w");fwrite(Resource id #4 , );fclose(Resource id #4);?> 2.) Now all thats left to do is make count.dat file and upload to your server and CHMOD to 777 Your done.Make Sure count.dat file is in same directory as where counter is being shown. :wink: Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 8, 2005 What language is this in? Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 8, 2005 its in php Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 8, 2005 What language is this in?It starts with <?php so its PHP language. Its simple, not too long and nice. The shorter the better if the desired output is the same. In this case I like this script. Well done.. Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 8, 2005 Well, yes, but that's not PHP. It looks like he took it out of a psuedo-code example and added a <?php tag to the beginning. He has assignment operators with nothing to assign the results to, invalid resource identifiers, and missing arguments. Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 8, 2005 Its in PHP .. i have tried this script .. works fine. Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 9, 2005 Will you please explain to me how this could posibly work. These are your mistakes: You have an assignment operator without anything to assign the result to-Lines 2 and 4 You have several references to Resource id #4. This is nowhere near correct PHP. Lines 2,3,4,7,8 and 9. You have missing arguments in some of the functions-Lines 3, 8, and 9 You have an increment operator without any variable to increment-Line 6 You display "Hits: ", but not the number of hits. This is the correct code re-written: <?php $file = "count.dat"; if(!($file = fopen($file,"r"))) die ("cannot open counter file"); $num = (int) fread($file, 20); fclose($file); $num++; echo "Hits: $num"; $file = fopen($file, "w"); fwrite($file,$num); fclose($file); ?> Share this post Link to post Share on other sites