Skip to content

Commit

Permalink
Dev : fixed issue : multi call of SELECT sql in dummy toke.
Browse files Browse the repository at this point in the history
Dev : move SELECT outside loop
  • Loading branch information
Shnoulle committed Jul 5, 2012
1 parent 4604bdf commit f8a1699
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions admin/tokens.php
Expand Up @@ -2682,6 +2682,14 @@
{
$data[$attr_name]=$_POST[$attr_name];
}
// select all existing tokens
$ntquery = "SELECT token FROM ".db_table_name("tokens_$surveyid")." group by token";
$ntresult = db_execute_assoc($ntquery);
$existingtokens=array();
while ($tkrow = $ntresult->FetchRow())
{
$existingtokens[]=$tkrow['token'];
}
$tblInsert=db_table_name('tokens_'.$surveyid);
$amount = sanitize_int($_POST['amount']);
$tokenlength = sanitize_int($_POST['tokenlen']);
Expand All @@ -2692,14 +2700,6 @@
$dataToInsert['firstname'] = str_replace('{TOKEN_COUNTER}',"$i",$dataToInsert['firstname']);
$dataToInsert['lastname'] = str_replace('{TOKEN_COUNTER}',"$i",$dataToInsert['lastname']);
$dataToInsert['email'] = str_replace('{TOKEN_COUNTER}',"$i",$dataToInsert['email']);
// select all existing tokens
$ntquery = "SELECT token FROM ".db_table_name("tokens_$surveyid")." group by token";
$ntresult = db_execute_assoc($ntquery);
$existingtokens=array();
while ($tkrow = $ntresult->FetchRow())
{
$existingtokens[]=$tkrow['token'];
}
$isvalidtoken = false;
$invalidtokencount=0;
while ($isvalidtoken == false && $invalidtokencount<50)
Expand Down

0 comments on commit f8a1699

Please sign in to comment.