Welcome Guest, Not a member yet? Register   Sign In
Unique data validation problem
#1

[eluser]jacobson[/eluser]
Hello, i have a problem with unique data validation. I have a function:
Code:
function unique($value, $params) {  
  
        $CI =& get_instance();  
        $CI->load->database();  
  
        $CI->form_validation->set_message('unique',  
            'The %s is already being used.');  
  
        list($table, $field) = explode(".", $params, 2);  
  
        $query = $CI->db->select($field)->from($table)  
            ->where($field, $value)->limit(1)->get();  
  
        if ($query->row()) {  
            return false;  
        } else {  
            return true;  
        }  
  
    }

and now even though i set the rule unique[users.username] ( my table and my field ) it doesnt work.. it shows nothing... what am I doing wrong ?




Theme © iAndrew 2016 - Forum software by © MyBB