Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Parse error on a } that needs to be there

    Hi,

    I've got a while loop in a while loop and it looks fine to me but its coming up with a parse error:

    Parse error: syntax error, unexpected '}' in ... on line 55

    With the following code:

    PHP Code:
    <?php
    $sql 
    'SELECT * FROM item;';
    $result $db->query($sql);
    while (
    $row $result->fetch()) {
          
    $sizes explode(';',$row["packet_size"]);         // Split the different packet sizes up
          
    $prices explode(';',$row["packet_price"]);       // Split the different packet prices up
          
    $packets count($sizes);                          // Count the number of different packet sizes
          
    $output2[] = '<h1>'.$row["item_name"].'</h1>';
          
    $output2[] = '<img src="images/'.$row["picture"].'" alt="'.$row["item_name"].'">';
          
    $output2[] = '<br>'.$row["description"].'<br>';
          
    $i=0;
          while (
    $i $packets){
          
    $output2[] = $sizes[i].'<br>';
          
    $output2[] = $prices[i].'<br><br>';
          
    $i++
          }     <--
    }
    echo 
    join('',$output2);
    ?>
    The } in question is the one closing the second while loop. This needs to be here so not sure why its complaining!

    I tried a do while loop as well but the same thing happens and a for loop doesn't complain but the section that should be printed out isn't.

    Any pointers much appreciated!
    Thanks, Flic

  • #2
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are missing a semi-colon (;) after i++ on the previous line.
    Last edited by frost; 07-20-2007 at 03:19 AM. Reason: typo

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    D'oh! Thats what comes from coding when tired I suppose!

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •