Welcome Guest, Not a member yet? Register   Sign In
Unable to access an error message happening only in production but not in development.
#1

[eluser]seonghuhn[/eluser]
I created a custom validation callback. It works fine in development and displays the correct error message.

However in production though the validation callback is correct I don't get my expected error but instead:

Quote:Unable to access an error message corresponding to your field name.

Why is this happening? I didn't think the field name matters since we set the message based on the function name.

This is my callback code.

Code:
function first_time($email_addr) {

    $this->db->select('id');
    $this->db->from('sent_coupons');
    $this->db->where('email_addr', $email_addr);
    $query = $this->db->get();

    if ($query->num_rows() == 0) {
      log_message('debug', $email_addr.' has not received a coupon yet');
      return TRUE;
    }

    $this->form_validation->set_message('first_time',
                                        'A coupon has already been sent to '.$email_addr.'. Only one coupon can be sent per email address.');
    log_message('debug', $email_addr.' has received a coupon, cannot get another');
    return FALSE;
  }

And this is how it is called
Code:
$this->form_validation->set_rules('email_addr', 'email address', 'trim|required|valid_email|callback_first_time');
#2

[eluser]seonghuhn[/eluser]
Turns out this bug was because of PHP 4. When I upgraded the hosting server to PHP 5 the problem was resolved.




Theme © iAndrew 2016 - Forum software by © MyBB