I can't get a for loop to work!

Discussion in 'PHP' started by meroving, Feb 11, 2009.

  1. #1
    set up php apache on my windows local machine

    Parts of php are working just fine, but I was havin issue with a 4 loop so I made a really simple one and it doesn't work either. I get a Parse error...here is the code.

    
    <?php
    for ($distance = 50; $distance <= 250; distance += 50) {
    echo $distance;
    }
    ?>
    
    Code (markup):
    I get the following firefox error...

    Parse error: parse error, expecting `')'' in C:\wamp\www\testing1\dbweb\chap1\pro1\freight.php on line 2
     
    meroving, Feb 11, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You missed a dollar sign on the 3rd distance.
     
    Danltn, Feb 11, 2009 IP
  3. meroving

    meroving Peon

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, I am dumb... forgot my $ after 3rd distance...
     
    meroving, Feb 11, 2009 IP
  4. SiteTalkZone

    SiteTalkZone Peon

    Messages:
    243
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hehe, silly mistakes like that have caused me hours of hunting before.
     
    SiteTalkZone, Feb 12, 2009 IP
  5. ToLynn.com

    ToLynn.com Banned

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's obviously a rather small grammatical error hard to spot.

    Use an advanced IDE development environment for PHP like Zend. It would instantly point out grammatical errors after your typing of a whole line.
     
    ToLynn.com, Feb 12, 2009 IP