This forum is now read-only. Please use our new forums at discuss.codecademy.com.

While Loops in PHP Forum

View Course » View Exercise

122 points
5796e2b24272794e6a89b72cf88a847b?s=140&d=retro
Submitted by
David Repasky
over 1 year ago

Bugs With This Lesson

I've finished every other lesson in PHP, except this one. Every time I pull it up, I get an error that I'm not connected to Codecademy. After I refresh, I immediately get the same error. As long as this error persists, I can't submit the activity.

My code is incorrect in that I need to change the operator for the while portion from == to !=. If I do that the loop should iterate once, and then stop.

<?php

           $loopCond = false;

    do {
        echo "<p>The loop ran even though the loop condition is false.</p>";
    }
    while ($loopCond == false);


    echo "<p>Now the loop is done running.</p>";
?>

I don't know how to get past these technical issues. I just completed the SQL course using the same internet connection I used for PHP. I also completed every other assignment in PHP.

What do I have to do to complete the course?


0 votes

permalink

You are making an infinite loop! Check this:

          $loopCond = false;

do {
    echo "<p>The loop ran even though the loop condition is false.</p>";
}
while ($loopCond == false);

You are saying to program never stop to loop. Look at the variable.

472 points
1ebd3a8a106b2d3d5981b537a773cad3?s=140&d=retro
Submitted by
Igtukra
over 1 year ago


0 votes

permalink

Thanks for the response. Now that you mention it you're right.

Unfortunately because of the connectivity problems, I can't commit any changes to the lesson. As stated before every other lesson has worked fine for me. This is the only lesson that I can't complete. I tried to find a way to contact an admin about this problem, but was unable. If an admin could look at this lesson, and resolve the problem I could continue.

122 points
5796e2b24272794e6a89b72cf88a847b?s=140&d=retro
Submitted by
David Repasky
over 1 year ago

1 Comment

51c14e598c1ccc92c1006609_222499189 Amrita Khurana Matta over 1 year ago

$loopCond = false;
do {
echo "The loop ran even though the loop condition is false.";
}
while (($loopCond) == true);
echo "Now the loop is done running.";
?>