title: custom form validation going wrong in codeigniter
body: <p>My custom function is not working. I am checking if passed value does not exist in the database it return error message. What I am doing wrong?<br>
  <strong>Controller function</strong></p>
  
  <pre><code>function sp_exists($str)
          {
              $this-&gt;user_model-&gt;sp_exists($str);
              $this-&gt;form_validation-&gt;set_message('sp_exists', 'The %s field does not exists');
          }
  </code></pre>
  
  <p><strong>Model function</strong></p>
  
  <pre><code>function sp_exists($str)
      {
          $this-&gt;db-&gt;where('member_id',$str);
          $query = $this-&gt;db-&gt;get('user');
          if ($query-&gt;num_rows() &gt; 0)
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  </code></pre>
  
  <p><strong>callback function</strong></p>
  
  <pre><code>$this-&gt;form_validation-&gt;set_rules('sponsor_id', 'Sponsor ID', 'trim|required|xss_clean|callback_sp_exists');
  </code></pre>