Jump to content

Recommended Posts

Hello,

 

I have a counter on my page which increments a column in my database every time a story on my site is viewed:

 

$result = mysql_query("SELECT * FROM stories WHERE story_id=".$id);
  $row = mysql_fetch_array($result);
  $i = $row['my_count'];
  $i++;
  $query = "UPDATE stories SET read_count = '$i' WHERE story_id=".$id;
  $result = mysql_query($query);

 

Is there anyway I could make it a bit better to not allow for things like a user sitting there and hitting refresh 15 times, and bots visiting the page, things like that really?

 

Thanks

You can use sessions to ensure they are only counted once.  Not sure about the bots issue.  For crawlers, which I'm not even sure if they would be counted, you would have to conditionally detect them.  Try Google, something like: Detect Crawlers.

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.