7 Replies - 517 Views - Last Post: 24 December 2008 - 10:17 AM Rate Topic: -----

#1 RayRayAngel  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 15-December 08

How To Prevent?

Posted 23 December 2008 - 03:22 AM

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?
Is This A Good Question/Topic? 0
  • +

Replies To: How To Prevent?

#2 ~NJ  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 52
  • Joined: 22-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#3 RayRayAngel  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 15-December 08

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.
Was This Post Helpful? 0
  • +
  • -

#4 ~NJ  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 52
  • Joined: 22-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#5 RayRayAngel  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 15-December 08

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 :)
Was This Post Helpful? 0
  • +
  • -

#6 Hary  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 427
  • Joined: 23-September 08

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.
Was This Post Helpful? 1
  • +
  • -

#7 mavrck  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 23-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#8 RayRayAngel  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 15-December 08

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!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1