Warptweet Posted May 23, 2007 Share Posted May 23, 2007 I use this code to count how many times an image is viewed on the viewing page on my website: $con = mysql_connect("?????","???????","????"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("???????", $con); mysql_query("UPDATE files SET views = views+1 WHERE file_id = '$id'"); So that works of course. Although, there is a problem. When somebody uploads a file on my website, they are also given a direct link to the image/picture. If they post that image/picture somewhere else on the internet, the above code is obviously not executed, meaning the view count is innacurate. How can I count how many times the image has been viewed including outside of my websites page? Is it possible to count how many times the image files has been requested from my server? Quote Link to comment https://forums.phpfreaks.com/topic/52591-counting-image-views/ Share on other sites More sharing options...
btherl Posted May 23, 2007 Share Posted May 23, 2007 This information is normally available in the webserver logs. Can you access those? I have php scripts which analyze the logs and generate counts of actual hits. Quote Link to comment https://forums.phpfreaks.com/topic/52591-counting-image-views/#findComment-259525 Share on other sites More sharing options...
Warptweet Posted May 23, 2007 Author Share Posted May 23, 2007 Yes, I have access to my webserver logs, I can access pretty much everything. Would you mind showing me how, or giving me your script if it's already made? I'd prefer being shown how or somewhat getting an explanation on how you would do it. I'd rather have my MySQL Database contain how many times it has been viewed, rather than acessing the webserver logs every time... Although, whichever way is easier for you is fine with me. Thanks, -Warptweet Quote Link to comment https://forums.phpfreaks.com/topic/52591-counting-image-views/#findComment-259572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.