While Loop Syntax Error


#1

Can anyone advise where I'm going wrong on 6.2 While Loop Syntax

It states the following

Undefined variable: loopond (line 9)
And now it's done.




Your First PHP while loop!


<?php
$loopCond = true;
while ($loopCond == true) {
echo "

The Loop is running

";
}
$loopCond = false;
echo "<p>And now it's done.</p>";
?>
</body>


#2

Tried this and now I get

Oops, try again. expected p:first-child text to be equal to The loop is running. but got The loop is running

Doesn't make sense to me - can anyone advise where I'm going wrong?




Your First PHP while loop!


<?php
$loopCond = true;
while ($loopCond == true){
//Echo your message that the loop is running below
echo "

The loop is running

";
$loopCond = false;
}
echo "

And now it's done.

";
?>


#3

I have exactly same problem. is it something what i did or is site problem?


#4

I'm having the same thing. There is just some bug that they haven't fixed yet. Mine looks like:




Your First PHP while loop!


<?php
$loopCond = true;
while ($loopCond == true){
echo"

The loop is running

";
	$loopCond = false;
}
echo "<p>And now it's done.</p>";
?>
</body>

I'm wondering why in SOME parts of Codeacademy they have 'report a bug' options, but not here. There are definitely bugs! I would think they'd want to know.


#5

To me, the program answered (even before I had started coding): unexpected ) in line 9.
But it were the authors of Codeacademy who had put the ) AND it was an absolutely necessary element.

I have reloaded the page, deleted the () from Codeacademy, then naturally I got the response 'unexpected { and when I then wrote ($loopCond == true) the loop worked.
So something must have wrong with a ) from CodeAcademy. But this bracket is a necessary element!

I have often in this course had to use such stupid tricks while my code was right, and it is a pity indeed that you cannot report bugs in PHP.

Euh... sorry. Was too optimistic. The loop worked finally, could see everything, but cannot submit it because of "Oops, try again. expected p:first-child text to be equal to The loop is running. but got And now it's done." that you also got...

I wonder what pro's would advise you if you asked them to fix this for you!!! I see in the next lesson that they say 'you have to put your code between p tags, but I did this still I got a first-child. My code was correct for I tried it in the next lesson and it worked.


#6

I have exactly the same problem. Wonder whether I will get my PHP course finished officially if all my lessons are not 'right' :smiling_imp:


#7

What is the error in this one?
I am getting the correct output on the full screen.


#8

Try adding "." after The loop is running


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.