Welcome Guest, Not a member yet? Register   Sign In
Can't read form values
#1
Exclamation 

Hello,

I've been playing with CRUD lately and I have this kind of problem that I didn't know how to fixed. I'm researching in the web to fixed this. Can someone tell me what is the error with this. I got an error A Database Error Occurred Error Number: 1048

My form:
Code:
<div class="activity-item">
                       <form action="" id="form" enctype="multipart/form-data" class="form-horizontal">
                           <input type="hidden" value="" name="id" />
                           <div class="form-body">
                               <div class="form-group">
                                   <div class="col-md-9">
                                       <input name="agencyname" placeholder="Agency Name" class="form-control" type="text">
                                       <span class="help-block"></span>
                                   </div>
                               </div>
                               <div class="form-group">
                                   <div class="col-md-9">
                                       <input name="category" placeholder="Category" class="form-control" type="text">
                                       <span class="help-block"></span>
                                   </div>
                               </div>
                               <div class="form-group">
                                   <div class="col-md-9">
                                       <input name="address" placeholder="Address" class="form-control" type="text">
                                       <span class="help-block"></span>
                                   </div>
                               </div>
                               <div class="form-group">
                                   <div class="col-md-9">
                                       <input name="acronym" placeholder="Acronym" class="form-control" type="text">
                                       <span class="help-block"></span>
                                   </div>
                               </div>
                           </div>
                       </form>                        
                       <button type="button" id="btnSave" onclick="save()" class="btn btn-primary">Save</button>
                   </div>
SCript:
Code:
<script type="text/javascript">

function save() {
       $('#btnSave').text('saving...');
       $('#btnSave').attr('disabled', true);
       var url;

       if (save_method == 'add') {
           url = "<?php echo site_url('agency/add')?>";
       } else {
           url = "<?php echo site_url('agency/update')?>";
       }
     
       $.ajax({
           url: url,
           type: "POST",
           data: $('#form').serialize(),
           dataType: "JSON",
           success: function(data) {

               if (data.status) //if success close modal and reload ajax table
               {                    
                   reload_table();
               } else {
                 
               }
               $('#btnSave').text('save'); //change button text
               $('#btnSave').attr('disabled', false); //set button enable


           },
           error: function(jqXHR, textStatus, errorThrown) {
               alert('Error adding / update data');
               $('#btnSave').text('save'); //change button text
               $('#btnSave').attr('disabled', false); //set button enable

           }
       });
   }    

   
</script>

Controller:
Code:
    public function add()
    {
        
        $this->_validate();
        $data = array(
            'name' => $this->input->post('agencyname'),
            'category' => $this->input->post('category'),
            'address' => $this->input->post('address'),
            'acronym' => $this->input->post('acronym'),

        );
        $insert = $this->agency->save_agency($data);
        echo json_encode(array("status" => TRUE));
    }
Model:
Code:
public function save_agency($data)
   {
       $this->db->insert($this->agencyTbl, $data);
       return $this->db->insert_id();
   }


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
Can't read form values - by Junie - 07-13-2017, 10:44 PM
RE: Can't read form values - by Martin7483 - 07-14-2017, 12:29 AM
RE: Can't read form values - by Junie - 07-14-2017, 12:59 AM
RE: Can't read form values - by salain - 07-14-2017, 03:23 AM
RE: Can't read form values - by Joel Catantan - 07-14-2017, 02:50 PM
RE: Can't read form values - by Paradinight - 07-14-2017, 11:14 PM
RE: Can't read form values - by Junie - 07-16-2017, 08:39 PM
RE: Can't read form values - by Martin7483 - 07-16-2017, 11:51 PM
RE: Can't read form values - by Junie - 07-17-2017, 12:12 AM
RE: Can't read form values - by Paradinight - 07-17-2017, 08:26 PM
RE: Can't read form values - by Junie - 07-18-2017, 06:27 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 02:01 AM
RE: Can't read form values - by Junie - 07-18-2017, 06:32 AM
RE: Can't read form values - by Junie - 07-18-2017, 06:39 AM
RE: Can't read form values - by Junie - 07-18-2017, 06:43 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 06:50 AM
RE: Can't read form values - by Junie - 07-18-2017, 07:09 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 07:14 AM
RE: Can't read form values - by Junie - 07-18-2017, 07:26 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 07:27 AM
RE: Can't read form values - by Junie - 07-18-2017, 07:32 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 07:45 AM
RE: Can't read form values - by Junie - 07-18-2017, 07:49 AM
RE: Can't read form values - by Martin7483 - 07-18-2017, 12:43 PM
RE: Can't read form values - by Junie - 07-18-2017, 06:55 PM
RE: Can't read form values - by salain - 07-18-2017, 09:58 PM
RE: Can't read form values - by Junie - 07-18-2017, 10:47 PM
RE: Can't read form values - by Martin7483 - 07-19-2017, 01:49 AM
RE: Can't read form values - by Junie - 07-19-2017, 05:12 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 04:29 AM
RE: Can't read form values - by Junie - 07-22-2017, 07:23 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 07:34 AM
RE: Can't read form values - by Junie - 07-22-2017, 07:39 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 07:44 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:03 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 08:08 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:16 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 08:26 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:31 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 08:37 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:39 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:37 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 08:42 AM
RE: Can't read form values - by Junie - 07-22-2017, 08:55 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 09:06 AM
RE: Can't read form values - by Junie - 07-22-2017, 09:16 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 09:26 AM
RE: Can't read form values - by Junie - 07-22-2017, 09:29 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 09:35 AM
RE: Can't read form values - by Junie - 07-22-2017, 09:45 AM
RE: Can't read form values - by Paradinight - 07-22-2017, 09:49 AM
RE: Can't read form values - by Junie - 07-22-2017, 07:38 PM
RE: Can't read form values - by Paradinight - 07-22-2017, 10:29 PM
RE: Can't read form values - by Junie - 07-25-2017, 04:20 AM
RE: Can't read form values - by Paradinight - 07-25-2017, 11:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB