Jump to content

Inserting data simultaneously into a mysql database


Recommended Posts

The problem is I have a database table that keeps track of people who are online (how have been active in the last 5 mins). A php script is run when ever they click a link on the page and it inserts the user into the database and delete all entrys that are over 5 minutes old.

 

The problem occurs when two users click on a link at almost the same time. This runs the script but only one of them is entered in the database the other is shown a defined error message \"Error inserting into database\".

 

Any ideas how I can get round this problem. I would really like know a fix for this problem as it will be helpful for a later day but is there a better way of find out who is online.

 

Michael

Well, that shouldn\'t be a problem I wouldn\'t think, unless your host is slow. MySQL is pretty fast :S

 

But maybe you could have the values stored into a .txt database to beginwith, and then have a script read through the values of that, and insert them into the DB.

explore the tutorial(s) here on using CRONTAB, this would be an appropriate occasion, to take a substantial load off your server, the file would run once every five minutes and do all the inserting then, unless you WANT to log all the movements of visitors (kinda pointless, when there are awstats and webalizer and such)

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.