This is a very common error, typically caused by a missing } used in PHP to denote content belonging to a WHILE, IF, or FOR loop, and it's mostly caused by a wrong indent habit.
it may happen that you might accidentally comment out a } when you comment out a line of code. For example:
while (x==y){
do this;
do that;}
If you decide you no longer want to "do that", be very careful to not remove the } as it's done here:
while (x==y){
do this;
// do that;}
Instead, the best practice is to keep } on its own line, so it can't be wrongly deleted/commented:
while (x==y){
do this;
// do that;
}