Jump to content


Photo

Inserting data simultaneously into a mysql database


  • Please log in to reply
2 replies to this topic

#1 mre2mpo

mre2mpo
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 02 December 2003 - 04:01 PM

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

#2 triphis

triphis
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 05 December 2003 - 02:31 AM

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.
Xac Attack

#3 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 05 December 2003 - 03:40 AM

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)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users