Jump to content

Counting Image Views


Warptweet

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.