Reputation: 1180
This while loop causes a Fatal error: Maximum execution time of 30 seconds exceeded. The query IS working. I tested the query in phpmyadmin.
Nothing is inside the loop in order to test whether it's content caused the error. It looks like the while loop is overloading. It seems that the script takes too long to load (thinking the query is too extended), not seeing any possibilities the loop to be infinite.
while($tags_db = mysqli_fetch_array(mysqli_query($link,
"SELECT *
FROM zk_terms
WHERE parent_id = 1 AND parent_type = 'archive' AND taxonomy = 'tag'"))){
}
Upvotes: 0
Views: 543
Reputation: 11832
Place your mysqli_query command outside your while and catch the result in a variable. Then use the variable with mysqli_fetch_array in the while .
otherwise, everytime the while condition is examined, the query is run again
Upvotes: 0
Reputation: 439
You need to modify your code:
$query = mysqli_query($link,
"SELECT *
FROM zk_terms
WHERE parent_id = 1 AND parent_type = 'archive' AND taxonomy = 'tag'");
while($tags_db = mysqli_fetch_array($query)){
// your code
}
Upvotes: 0
Reputation: 282895
You're re-executing the query every iteration, and then mysqli_fetch_array
is fetching only the first result each loop. You have to move mysqli_query
outside the loop and assign it to a variable.
Upvotes: 6