I have a script that does a lot of math using variables that change a lot according to the data stored in an SQL table. I have some people who just refresh the page over and over and over several times a second. When they do this it seems like the full code doesn't execute and then some of the values in the database get messed up. How do I prevent this from happening? Could this even be possible?
How To Prevent?
Page 1 of 17 Replies - 456 Views - Last Post: 24 December 2008 - 10:17 AM
Replies To: How To Prevent?
#2
Re: How To Prevent?
Posted 23 December 2008 - 04:10 AM
It may be possible that some of the queries are not being run as the page is being cut off. My suggestion would be to move the queries to the top of the page so they are executed first.
#3
Re: How To Prevent?
Posted 23 December 2008 - 04:12 AM
Yeah I'm moving as much to the top as I can and cleaning it up as much as possible to see if that helps.
#4
Re: How To Prevent?
Posted 23 December 2008 - 04:44 AM
Can you give us any idea of what you're queries are like?
Instead of having the queries in the file that is getting called, have them in another file. Then in the original file, replace the queries with a simple include() which would essentially shorten the queries to one line. That way, the server can run the queries in the background even if a user navigates away from a page.
Instead of having the queries in the file that is getting called, have them in another file. Then in the original file, replace the queries with a simple include() which would essentially shorten the queries to one line. That way, the server can run the queries in the background even if a user navigates away from a page.
#5
Re: How To Prevent?
Posted 23 December 2008 - 04:53 AM
Funny you said to do that because I am right now just to make things easier to read
#6
Re: How To Prevent?
Posted 23 December 2008 - 04:57 AM
You could use a Javascript HTTP request (AJAX) to initiate the procedures that take a long time, so you can display a "please wait" on the same screen, until the result is there. You even want to disable the submit button there or use the Javascript to prevent resending the request.
#7
Re: How To Prevent?
Posted 24 December 2008 - 09:21 AM
Your desired functionality is called 'database transactions'. They allow a set of queries, inserts, etc. to to completed as a batch and can be rolled back if the full set is not completed.
If you're using MySQL, you can read about them at http://dev.mysql.com...ansactions.html.
If you're using MySQL, you can read about them at http://dev.mysql.com...ansactions.html.
#8
Re: How To Prevent?
Posted 24 December 2008 - 10:17 AM
VERY Excellent information from all. The ideas are certainly flowing right now. I'll be sure to read up on that page mvrck!!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|