DamienRoche Posted September 10, 2008 Share Posted September 10, 2008 So I just got into while loops and have constructed this beast: $e1fname = "text"; ///////////$e2fname etc. etc. $e1sname = ""; "" "" $e1passport = "text"; "" "" $loop = "1"; $limit = "3"; $Y = "0"; $N = "0"; while ($loop <= $limit){ $fb = "e".$loop."fname"; $sb = "e".$loop."sname"; $pb = "e".$loop."passport"; $cb = "e".$loop."check"; if($cb!=""){ if($fb!="" && $sb!="" && $pb!=""){ $Y = $Y + 1;}else{$N = $N + 1;} } } if($N > 0) {echo "The while loop returned an N";} The problem here is that the loop is timing out when it should only run it 3 times? is it because of the nested if statements? What is best practice here? or have I missed something, yet again? Thanks. Link to comment https://forums.phpfreaks.com/topic/123570-solved-interesting-while-loop-keeps-timing-out/ Share on other sites More sharing options...
JasonLewis Posted September 10, 2008 Share Posted September 10, 2008 You need to increment $loop. You don't need the talking marks around numbers either. Link to comment https://forums.phpfreaks.com/topic/123570-solved-interesting-while-loop-keeps-timing-out/#findComment-638166 Share on other sites More sharing options...
DamienRoche Posted September 10, 2008 Author Share Posted September 10, 2008 OMG I cannot believe I did not increment the loop. I can only code for so long before ALL of my problem solving skills are washed away with the last bit of coffee in my mug. Thank you again!! Link to comment https://forums.phpfreaks.com/topic/123570-solved-interesting-while-loop-keeps-timing-out/#findComment-638168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.