[Solved] Can’t Insert to database CodeIgniter


Change your controller function with below code

I think You are calling wrong model for inserting rating

  public function rateform($username,$id,$name) {
    $this->load->Model('Keluhan'); // load your model 
          $rating = $this->input->post('rating');
        $name2 = urldecode($name);
           $data = array
               (
                'id' => $this->input->post('id'),
                'username' => $this->input->post('username'),
               'rating' => $this->input->post('rating')



                );


               $result = $this->Keluhan->InsertRating($data); // change your model name where you want to insert rating
                if ($result == TRUE) {
                    $data['message_display'] = 'Registration Successful !';

              } else {
                   $data['message_display'] = 'Username already exist!';

               }
}

solved Can’t Insert to database CodeIgniter