Parse error: syntax error, unexpected T_ELSE on line 15


#1

Although it says i passed i am getting and error syntax please help


#2

@pedrosuarez
Can you paste your code in this format

```
  replace this line with your code, leave backticks
```

#3

remove the semicolon on line 14
and in php you cannot have an else without an if


#4

   $practice = 0;
        //write your do-while loop below
        do {
            
            if ($practice < 100)
            echo "<p>True </p>";
            }
      while ($practice > 10);{
      echo "<p>False</p>";
      
      }

i re wrote the code


#5

@pedrosuarez

Remember there should be a curly bracket { after your condition so the } doesn't close anything.

Remove the semicolon.


#6

Simplest do/while

<?php
    $practice = 0;

    do {
    echo "False";
    } 

while ($practice > 10);

 ?>

While checks if $practice is greater than 10, it's not, the loop ends and echos do.


#7

@codelazy
Your code isn't good. Remember a while loop structure looks like this:

while(condition) {
//We execute the code in the curly brackets, watch out for infinite loop!
}

#8

it's a do while chk, if $practice is more than 10, we'll get an infinite loop. that simple code works and passes through. my initial code is more complex for my course, this was a quick thing to show how do/while chks and work.


#9

where does that happen?


#10

run the script, you should get whatever is asked to echo in the do.


#11

in reference to the statement. it sounds like you were saying do is echoed and not the statements inside do


#12

without the if and else statements? no


#13

@rydan
Wait where does he echoed do?


#14

@miniapple8888 i was just addressing the fact that @codelazy's statement here

needs to rephrased because i think what he wanted to write was that the content of the do block is executed


#15

thank you
you guys are the pros, not me :- )
thats the best i could do with the original code without the ifs and else statements.
And in trying to make that work i lost my own course code haha