Welcome Guest, Not a member yet? Register   Sign In
$this->form_validation->error_array() not work
#1

please help, i'll try this code in my localhost is working but not in may hosting server.

PHP Code:
public function register() {
         
$this->load->library('form_validation');
           
$this->output->set_content_type('application_json');
           
$this->form_validation-set_rules('name','UserName','required|min_length[4]|max_length[16]|is_unique[user.username]');
           if (
$this->form_validation->run() == false){
               
$this->output->set_output(json_encode([$this->form_validation->error_array()]));
               return 
false;
           }
  } 
www.arthnugraha.com
Learning by doing
Reply
#2

What is the error on you hosting server. I think it could be a path problem or settings.

Reply
#3

(12-11-2014, 03:01 AM)artha.nugraha Wrote: please help, i'll try this code in my localhost is working but not in may hosting server.


PHP Code:
public function register() {
 
        $this->load->library('form_validation');
 
          $this->output->set_content_type('application_json');
 
          $this->form_validation-set_rules('name','UserName','required|min_length[4]|max_length[16]|is_unique[user.username]');
 
          if ($this->form_validation->run() == false){
 
              $this->output->set_output(json_encode([$this->form_validation->error_array()]));
 
              return false;
 
          }
 
 


Please turn on your error output and post that with this
try ini_set('display_errors', 1); in your index.php file.

Without seeing the error, could be
is_unique[user.username] is not working do to not being able to connect to database properly.
or
$this->output->set_output(json_encode([$this->form_validation->error_array()])); is not parsing correctly.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB