我为什么会出乎意料的'}'? [关闭]

As a fairly new user to php I thought that the code attached should work. ie; all brackets are balanced. But in firebug-xdebug, it is saying that there is a Parse error: syntax error, unexpected '}'. The line it refers to I have highlighted in my code. What is the cause of this. Thanks

<?php

foreach ($array as $box) {
    $box = mysql_real_escape_string($box);
    $sql = "SELECT item FROM temp WHERE item = '$box'";
    $result = mysql_query($sql) or die ('{"opp":"error","box":"' . mysql_error() . '"}');


    if (mysql_num_rows($result) > 0) {

        $outString .= $box . ','

  }<---THIS LINE ERROR
}

?>

You should put a semicolon at the end of line $outString .= $box . ',':

if (mysql_num_rows($result) > 0) {
    // ---------------------v
    $outString .= $box . ',';
}

because of missed semicolon fix: $outString .= $box . ',';

<?php

foreach ($array as $box) {
  $box = mysql_real_escape_string($box);
  $sql = "SELECT item FROM temp WHERE item = '$box'";
  $result = mysql_query($sql) or die ('{"opp":"error","box":"' . mysql_error() . '"}');


  if (mysql_num_rows($result) > 0) {

    $outString .= $box . ',' ;  <<-- Missed semicolon

   }
 }

?>