I have a php page that runs a series of queries and loops as shown below, but I am getting a 500 Internal Server Error
which I can only assume is down to a timing out.
The main loop should loop through about 3000 records but I have added the if statement to check if it works with a lower number which it does (the userIDs are 1, 2, 3, 4 etc and therefore indicate the number of records being looped through). Up this number to 2000 and I get the error after about 1 minute.
ini_set('max_execution_time', 9000);
...
$sqlSelect = "SELECT DISTINCT userID FROM tblResults;";
$selectedIDs = mysql_query($sqlSelect);
while($resultRow = mysql_fetch_array($selectedIDs)) {
$userID = $resultRow['userID'];
set_time_limit(0);
if ($userID < 500) {
....
series of queries and loops
....
}
}
I have tried setting the max_execution_time and have put set_time_limit(0); at the beginning of any loop but this does not seem to help. I can't find any errors in any of logs relating to the error.
Also, it is not an issue with the data as if I try:
if ($userID >= 500 && $userID < 1000)
if ($userID >= 1000 && $userID < 1500)
if ($userID >= 1500 && $userID < 2000) etc
it all works. But try:
if ($userID < 2000) [ie the same data but all at once]
if fails.
Any thoughts?