doggee7 Posted January 22, 2009 Share Posted January 22, 2009 Hello all, I have a looping structure that in super simplified format looks like this: for( "while theres results from mysql query" ) { for( "every day in the pst six months" ) { "Several other complex child loops, involving variable assignment, if-else and sql calls" } } The problem is, when i run this script with any more than three results from the original query, the whole page fails. After setting a counter within several of the loops, i've determined that the script dies at different iterations of the "for every day in the past six months" loop. I've checked the possibility of both timeout restrictions, and php memory limits, and i seem to be well within the boundaries of both. I am all out of ideas. Other than the possibilty of php getting lost in a sea of thousands of if's and then's i can't figure out how to solve this problem. If the script had errors, it should die at the same iteration everytime. Can anyone help me out?? Quote Link to comment https://forums.phpfreaks.com/topic/141880-solved-complex-looping-structure-dies-at-variable-iterations/ Share on other sites More sharing options...
trq Posted January 22, 2009 Share Posted January 22, 2009 Can anyone help me out?? Not without seeing some actual & relevent code. Quote Link to comment https://forums.phpfreaks.com/topic/141880-solved-complex-looping-structure-dies-at-variable-iterations/#findComment-742845 Share on other sites More sharing options...
doggee7 Posted January 22, 2009 Author Share Posted January 22, 2009 Thorpe, Turns out it was a timeout issue! A friend pointed me to set_time_limit(). When i set it to zero, though it took a full 59 seconds, my script finished without failing. Thanks for the swift response though! Quote Link to comment https://forums.phpfreaks.com/topic/141880-solved-complex-looping-structure-dies-at-variable-iterations/#findComment-743250 Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2009 Share Posted January 22, 2009 It's never very efficient to put a query inside of a loop that is iterating through related query results. A correct JOIN query between the related data will probably reduce the time it takes to about one second and will simplify the code as well. Quote Link to comment https://forums.phpfreaks.com/topic/141880-solved-complex-looping-structure-dies-at-variable-iterations/#findComment-743254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.