title: HTTP 500 error using CodeIgniter Form Validation callback functions
body: <p>So I'm trying to use a callback function with the Form_validation library in CodeIgniter (v2.1.4) to check whether a user with a given username or email exists in the database before creating a new user.</p>
  
  <p>login.php (Controller)</p>
  
  <pre><code>function create_member()
  {
      $this-&gt;load-&gt;library('form_validation');
      $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'trim|required|min_length[4]|callback_value_check[USERNAME]');
  
      if($this-&gt;form_validation-&gt;run() != FALSE)
      {
          // Validation passed; create the new user.
          $this-&gt;load-&gt;model("members_model");
          if($query = $this-&gt;members_model-&gt;create_member())
          {
              // Load the success page view.
          }
          else
          {
              // Reload the signup page view.
          }
      }
      else
      {
          // Reload the signup page view.
      }
  }
  
  function _value_check($value, $column)
  {   
      $this-&gt;load-&gt;model("members_model");
      if($this-&gt;members_model-&gt;check_exist_value($column, $value))
      {
          $this-&gt;form_validation-&gt;set_message('value_check', '%s is already taken.');
          return FALSE;
      }
      else
      {
          return TRUE;
      }
  }
  </code></pre>
  
  <p>members_model.php (Model)</p>
  
  <pre><code>function check_exist_value($column, $value)
  {
      $this-&gt;db-&gt;where($column, $value);  
      $result = $this-&gt;db-&gt;get('MEMBERS');
  
      if($result-&gt;num_rows() &gt; 0)
      {
          // A user with that unique value already exists in the database.
          return TRUE;
      }
      else
      {
          // There is no user with that unique value in the database.
          return FALSE;
      }
  }
  </code></pre>
  
  <p>As seen in the code above, I'm only currently testing for an existing username. The standard validation messages appear correctly (i.e. required, min_length, etc). However, if I enter a value that I know to be already in the database (meaning the custom callback validation function should fail) I instead get an HTTP 500 error (Chrome's default 'Server error' page).</p>
  
  <p>Does anyone have any insight as to why I'm getting an HTTP 500 error instead of seeing my custom error message?</p>