mre2mpo Posted December 2, 2003 Share Posted December 2, 2003 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 Quote Link to comment https://forums.phpfreaks.com/topic/1452-inserting-data-simultaneously-into-a-mysql-database/ Share on other sites More sharing options...
triphis Posted December 5, 2003 Share Posted December 5, 2003 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. Quote Link to comment https://forums.phpfreaks.com/topic/1452-inserting-data-simultaneously-into-a-mysql-database/#findComment-4828 Share on other sites More sharing options...
Arenium Posted December 5, 2003 Share Posted December 5, 2003 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) Quote Link to comment https://forums.phpfreaks.com/topic/1452-inserting-data-simultaneously-into-a-mysql-database/#findComment-4829 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.