Vivid Lust Posted July 22, 2008 Share Posted July 22, 2008 I need some beginner's php help on a counter which only says: array :s here's my coded: Counts: <?php $count_my_page = ("hit.txt"); $hits = file($count_my_page); $hits = $hits ++; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits"); fclose($fp); ?> Resets: <?php $count_my_page = ("../hit.txt"); $hits = file($count_my_page); $hits = "0"; $fp = fopen($count_my_page , "w"); fwrite($fp , "$hits "); fclose($fp); ?> Thanks in advanced if someone can help! Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/ Share on other sites More sharing options...
.josh Posted July 22, 2008 Share Posted July 22, 2008 how about posting the code that is displaying "array" Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/#findComment-596762 Share on other sites More sharing options...
Vivid Lust Posted July 22, 2008 Author Share Posted July 22, 2008 <?php include("../hit.txt"); ?> Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/#findComment-596770 Share on other sites More sharing options...
ChompGator Posted July 22, 2008 Share Posted July 22, 2008 What are you wanting this counter to do? I coded one that has intelligence based - behind it.. It counts up 1 for every visitor that visits the site, but then records that users IP address in a database, so if they ever come back to the site again using that computer - the counter doesnt go up by 1, it just stays the same... I can post the code and explain it, if youd like Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/#findComment-596774 Share on other sites More sharing options...
Vivid Lust Posted July 22, 2008 Author Share Posted July 22, 2008 its just a hit counter... i think the problem is how it resets and the code cant ++ ??? Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/#findComment-596776 Share on other sites More sharing options...
john-formby Posted July 22, 2008 Share Posted July 22, 2008 <?php $fp = fopen("hit.txt", "r"); $hits = fread($fp, 1024); fclose($fp); $hits = $hits + 1; echo "Count = " . $hits . "</p>"; $fp = fopen("hit.txt", "w"); fwrite($fp, $hits); fclose($fp); ?> That should work Link to comment https://forums.phpfreaks.com/topic/116054-solved-counter-help/#findComment-596779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.