Can't echo inside IF statement?
===

I'm having the Darndest Error... The code below is running as expected, and visiting both halves of the IF statement as expected (i can tell, because i'm getting both "TRUE" and 'FALSE' added to the error log, and getting them added above the output for the condition that caused them

But when i visit the 'TRUE' part of the IF, it doesn't echo for some reason. I know that code section is not getting skipped (because the [error_log("TRUE");] still gets run.

CODE SUMMARY: Step through a list of states, output half a HTML tag, (conditionally add a middle bit), output the end half.

    function createStateOptions($country, $state) {
      $sql = "SELECT * FROM tbl_state WHERE disabled != true AND deleted != true AND     country = :country ORDER BY state ASC";
      $result = executeSQL($sql, array(':country' => $country));
      if (is_array($result)) {
          foreach ($result as $record) {
            echo '<option value="' . htmlentities($record["state"], ENT_QUOTES) . '" ';
        if($state == $record["state"]) { echo " selected"; error_log("TRUE");} else    {error_log("FALSE");}
        echo '>' . htmlentities($record["state"], ENT_QUOTES) . '</option>';
        error_log("'".$state."' == '".$record["state"]."'"); 
        }
      }
    }

Sorry about the state of the code, it used to be a little more elegant before i started cutting it up to simplify the logic and then bashed in a whole bunch of logging