Jul 20, 2008

Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > AJAX

free web hosting

Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.

sonesay
Heres my merit system at its current stage. http://sonesay.trap17.com/index.php
note: select a character from the drop down list to see output.

I've been working on this locally on my mac and because of little or no delay I did not see the problem until I decided to upload to the WWW. The problem lies in the adding of merits to each category. Although there are integrity checks on the PHP side before executing the update to mysql database it somehow fails because of the lag.
i.e multiple 'add' buttons can be pressed before the section gets reloaded. so if your modifying the 'Combat Skill' category and its 19/20 you should only be able to add one more merit. But because of page reloading delay you are able to hit more buttons before it finishes reloading.

my function to modify merits.
CODE
function modify_merit($mm_c_id, $mm_mode, $mm_merit, $mm_combo_limit, $mm_item_limit, $mm_table) {
include('../db.php');

if ($mm_mode == "remove") {
// check if merit is equal or above 1 before lowering by 1
// get users merits
$q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id;
$r1 = mysql_query($q1, $link);
while ($m = mysql_fetch_array($r1)) {
$mm_new_level = $m[$mm_merit];
}
if($mm_new_level > 0) {
$mm_new_level--;
// update hp level
$q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id;
mysql_query($q2, $link);
}
}
if ($mm_mode == "add") {
$q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id;
$r1 = mysql_query($q1, $link);
while ($m = mysql_fetch_array($r1)) {
$mm_new_level = $m[$mm_merit];
}
// check if under max combo and item limit before adding.
if($mm_new_level < $mm_item_limit && $mm_new_level < $mm_combo_limit) {
$mm_new_level++;
// update hp level
$q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id;
mysql_query($q2, $link);
}
}
}


each button pressed is added like this
CODE
if($merit == "sword_level") {
modify_merit($c_id, $mode, $merit, 20, 8, 'combat_skill');
}



I know I cant blame lag being the cause of my problem its my code. There are two options at this stage I can think of

1. Redo all the sections and reload all Div's in the same category all at once so there is no way to press more then 2 buttons. e.g if HP merit is incresed the whole HPMP div reloads at once so there is no chance to hit the add MP button causing 8 max combo constraint to fail.

2. Use java script to disable all add buttons in the category being modified until its fully reloaded(not sure this will work).

What do you think would be the best way to fix this?

 

 

 


Reply

moodsey211
I think the second one will work.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:


Searching Video's for integrity, checks, failing, multiple, ajax, request, checks, fail, due, lag,
advertisement



Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE