View Full Version : Parse error on a } that needs to be there

07-20-2007, 04:07 AM

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:

$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>';
while ($i < $packets){
$output2[] = $sizes[i].'<br>';
$output2[] = $prices[i].'<br><br>';
} <--
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

07-20-2007, 04:18 AM
You are missing a semi-colon (;) after i++ on the previous line.

07-20-2007, 02:15 PM
D'oh! Thats what comes from coding when tired I suppose!