jquery - php for statement is working only once -
here problem,
i have php statement, , whatever do, goes once through it... check vars it, , write them sure... seems ok... never works...
here code ($user initialized session var):
for($i=0;$i<=($size);$i++){ $test = $db->prepare("insert `test`(`val`) values ('in!!')"); $test->execute(); $name = ''; if($i==0){ $name = $db->quote("test"); }else{ $name = $db->quote("number $i"); } $number = $db->quote($i); //insert $query = "insert `test`(`name`,`number`) values ($name,$number)"; $insert = $db->prepare($query); if($insert->execute()){ $id = ''; $get = $db->prepare("select last_insert_id();"); $get->execute(); foreach($get $myid){ $id = $myid[0]; } if(!(isrel($db,$user))){ if(!(setisrel($db,$user,1))){ $error = false; } } if(!(hasrel($db,$etabid))){ if(!(sethasrel($db,$id,1))){ $error = false; } } if(!(buildrelationship($db,$id,'2'))){ $error = false; } if(!(buildrelationship($db,$id,'3'))){ $error = false; } }else{ $error = false; } $check1 = ''; $check2 = ''; $check3 = ''; $check4 = ''; if(is_numeric($size)){ $check1 = "ok"; } if($i<=$size){ $check2 = "ok"; } $test = $db->prepare("insert `test`(`val`) values ('size numeric? $check1 -- smaller? $check2')"); $test->execute(); }
answer :
in!! size numeric? ok -- smaller? ok
where wrong...?
thanx !
(this php code called .ajax request -jquery- don't think has because did similar stuff this...)
the size var set 2 or 3, never less! checked
edit :
well,
here code before statement :
function createstages($db,$user,$size){ $error = true; $size= intval($size);
i don't thing it'll help..
sounds type conversion getting messed then. remove $size = intval($size), , replace condition in loop $i <= (int) $size.
Comments
Post a Comment