lundi 21 août 2017

JS Random and SQL loop

I'm having a little problem regarding the randomized number and saving it to the database. Locally I'm not having this problem but once I use my host/website once I get to the 40th number it will just stop and return ERR_EMPTY_RESPONSE

What I have is this

JS:

counter=0;item_length=$('#howmanynumber').va();
function RandNum(){x=Math.floor(Math.random()*899999) + 100000;
  $.post('query.php',{rnum:x},function(d){if($.trim(d)){
    counter++;
    /**print*/
    if(counter<item_length){
      RandNum();
    }
  }else{
    RandNum();
  }}

PHP:

$rnum=$_POST['rnum'];
$sql="SELECT number FROM list WHERE number='$rnum'";
$result=mysqli_query($connect,$sql);
$count=mysqli_num_rows($result);

if(!$count){
  $sqli="INSERT INTO list(number) VALUES('$rnum')";
  mysqli_query($connect,$sqli);
  return true;
}else{
  return false;
}

Locally I can even generate up to 1000 numbers I can't figure out why it stops to 40 on my website

Host: GoDaddy

B'rgrds,




Aucun commentaire:

Enregistrer un commentaire