echo json_encode() is returning NULL
<p>I am trying to pass data to a php page via ajax, the data gets inserted to the database, then I need to pick up the last insert and pass the back to update a select menu with that last insert selected.  The database gets updated correctly, but Im getting a NULL return for the echo json_echo($data);</p>

<p>Been stuck on this all day, would really appreciate the help!!!</p>

<pre><code>if (empty($_POST) === false &amp;&amp; empty($errors) === true) {

      $company_id   = $_POST['company_id'];
      $patient_id   = $_POST['addpatient_id'];
      $first_name   = $_POST['addpatient_firstname'];
      $last_name    = $_POST['addpatient_lastname'];
      $dob          = $_POST['addpatient_dob'];
      $updated      = $_POST['patient_added'];


      $update = array();
      array_walk($update_data, 'array_sanitize');

      foreach($update_data as $field=&gt;$data) {
          $update[] = '`' . $field . '` = \'' . $data . '\'';
      }

      mysql_query("INSERT INTO `lab`.`patients` (`company_id`, `patient_firstname`, `patient_lastname`, `patient_dob`, `patient_added`) VALUES ('$company_id', '$first_name', '$last_name', '$dob', '$updated')");
      $last_patient_id = mysql_insert_id();

      $result = mysql_query("SELECT `patient_id`, `patient_firstname`, `patient_lastname`, `patient_dob` FROM `patients` WHERE `patient_id` = $last_patient_id");
      $data[] = mysql_fetch_assoc($result);
}
      echo json_encode( $data );
</code></pre>
