Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to access an error message corresponding to your field name
    text
    copied!<p>I have a callback function that check_captcha which sees if <code>$row</code> is <code>==0</code> or <code>== 1</code> (this information is queried from sql). </p> <p>The problem is that I can not call it from <code>$self-&gt;form_validation-&gt;set_rule('captcha', 'call_back_check_captcha')</code> due to the fact that my function takes in a <code>$row</code> var. The way I'm calling it now I get a Unable to access error message. How can I make this work?</p> <pre><code>function check_captcha( $row) { if($row ==0)//didnt find any { $this-&gt;form_validation-&gt;set_message('captcha', 'text dont match captcha'); return FALSE; } else { return TRUE; } } function create_member() { $past = time() - 7200; $this-&gt;db-&gt;query("DELETE FROM captcha WHERE captcha_time &lt;".$past); $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word =? AND ip_address =?"; $binds = array($_POST['captcha'], $this-&gt;input-&gt;ip_address(), $past); $query= $this-&gt;db-&gt;query($sql, $binds); $row = $query-&gt;row(); //row query rows : if it found an entry =1 $self-&gt;check_captcha($row-&gt;count); //VALIDATIONS $this-&gt;form_validation-&gt;set_rules('first_name', 'First Name', 'trim|required'); $this-&gt;form_validation-&gt;set_rules('last_name', 'Last Name', 'trim|required'); $this-&gt;form_validation-&gt;set_rules( 'email_address', 'Email Address', 'trim|required|valid_email|unique[user.email_address]'); $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'trim|required|min_length[4]|unique[user.username]'); $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'trim|required|min_length[4]|max_leng[32]'); $this-&gt;form_validation-&gt;set_rules('password2', 'Password Confirmation','trim|required|matches[password]'); if(!$_POST['captcha']){ $this-&gt;form_validation-&gt;set_rules('captcha', 'Captcha','trim|required');}else{ $this-&gt;form_validation-&gt;set_rules('captcha', 'Captcha', 'callback_check_captcha');} if($this-&gt;form_validation-&gt;run()==FALSE) { //this -&gt; to the curr obj(UserController) &amp;&amp; registraion() points to the the function in controller $this-&gt;registration(); //reloads reg page so they can fill out right stuff } else </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload