title: backend not adding books to android app sql
body: <p>i have made an ebook android app everything works fine but the backend code of admin age which is written in php and javascript .the admin has a function to add book known as savebook the "savebook" function is not working please help me guys....every time i try to add a book i it just shows a failed message but when i add the book to the database manually via phpmyadmin it works here is the code to that function 
  the problem is in last function (what is think) but stil i would appreciate if you guys find some other mistake in the code the whole website is working but this only function  is not working the app in on android platform the backend is done using codeigniter and the app is linked to a database which maintains the details of book </p>
  
  <pre><code>&lt;?php
  $this-&gt;load-&gt;view('admin/comman/header');
  ?&gt;
  
  &lt;div class="clearfix"&gt;&lt;/div&gt;
  
  &lt;div class="content-wrapper"&gt;
      &lt;div class="container-fluid"&gt;
          &lt;!-- Breadcrumb--&gt;
          &lt;div class="row pt-2 pb-2"&gt;
              &lt;div class="col-sm-9"&gt;
                  &lt;h4 class="page-title"&gt;Add Book&lt;/h4&gt;
                  &lt;ol class="breadcrumb"&gt;
                      &lt;li class="breadcrumb-item"&gt;&lt;a href="javaScript:void();"&gt;Dashboard&lt;/a&gt;&lt;/li&gt;
                      &lt;li class="breadcrumb-item"&gt;&lt;a href="javaScript:void();"&gt;Books&lt;/a&gt;&lt;/li&gt;
                      &lt;li class="breadcrumb-item active" aria-current="page"&gt;Add Book&lt;/li&gt;
                  &lt;/ol&gt;
              &lt;/div&gt;
              &lt;div class="col-sm-3"&gt;
                  &lt;div class="btn-group float-sm-right"&gt;
                      &lt;a href="&lt;?php echo base_url(); ?&gt;index.php/admin/booklist" class="btn btn-outline-primary waves-effect waves-light"&gt;Books List&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;!-- End Breadcrumb--&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-lg-10 mx-auto"&gt;
                  &lt;div class="card"&gt;
                      &lt;div class="card-body"&gt;
                          &lt;div class="card-title"&gt;Add Book
                              &lt;form id="edit_video_form" enctype="multipart/form-data"&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-1"&gt;Book Name&lt;/label&gt;
                                      &lt;input type="text" required value="" class="form-control" name="input_name" id="input-1"&gt;
                                  &lt;/div&gt;
  
                                  &lt;input type="hidden" name="id" value=""&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-3"&gt;Book Cost&lt;/label&gt;
                                      &lt;select name="select_cost" required class="form-control" id="purpose"&gt;
                                          &lt;option value="0"&gt;Free&lt;/option&gt;
                                          &lt;option value="1"&gt;Paid&lt;/option&gt;
                                      &lt;/select&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group" id="business" style="display:none"&gt;
                                      &lt;label for="input-1"&gt;Book price&lt;/label&gt;
                                      &lt;input type="text" required value="" class="form-control" name="input_price" id="input-1" placeholder="Enter Book Price"&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-2"&gt;Book Category&lt;/label&gt;
                                      &lt;!-- DropDown --&gt;
                                      &lt;select name="select_category" required class="form-control"&gt;
                                          &lt;option value=""&gt;Select Category&lt;/option&gt;
                                          &lt;?php $i = 1;
                                          foreach($categorylist as $cat) { ?&gt;
                                              &lt;option required value="&lt;?php echo $cat-&gt;cat_id; ?&gt;"&gt;&lt;?php echo $cat-&gt;cat_name; ?&gt;&lt;/option&gt;
                                              &lt;?php $i++;
                                          } ?&gt;
                                      &lt;/select&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-2"&gt;Book Author&lt;/label&gt;
                                      &lt;!-- DropDown --&gt;
                                      &lt;select name="select_author" required class="form-control"&gt;
                                          &lt;option value=""&gt;Select Author&lt;/option&gt;
                                          &lt;?php $i = 1;
                                          foreach($authorlist as $cat) { ?&gt;
                                              &lt;option value="&lt;?php echo $cat-&gt;a_id; ?&gt;"&gt;&lt;?php echo $cat-&gt;a_title; ?&gt;&lt;/option&gt;
                                              &lt;?php $i++;
                                          } ?&gt;
                                      &lt;/select&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-1"&gt; Book Cover Poster&lt;/label&gt;
                                      &lt;input type="file" required class="form-control" name="input_bookcover" id="input-1" placeholder="select Book Cover image"
                                             onchange="readURL(this,'showImage')"&gt;
                                      &lt;input type="hidden" name="input_bookcover" value=""&gt;
                                      &lt;p class="noteMsg"&gt;Note: Image Size must be less than 2MB.Image Height and Width less than 1000px.&lt;/p&gt;
                                      &lt;img id="showImage" src="&lt;?php echo base_url() . 'assets/images/placeholder.png'; ?&gt;" height="100" width="100" alt="your image"/&gt;
                                  &lt;/div&gt;
  
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-1"&gt; Upload Sample Book&lt;/label&gt;
                                      &lt;input type="file" required class="form-control" name="input_sample_book" id="input-1" placeholder="select Sample Book"&gt;
                                      &lt;input type="hidden" name="input_sample_book" value=""&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-1"&gt; Upload Full Book&lt;/label&gt;
                                      &lt;input type="file" required class="form-control" name="input_full_book" id="input-1" placeholder="select Full Book"&gt;
                                      &lt;input type="hidden" name="input_full_book" value=""&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;label for="input-1"&gt;Book Description&lt;/label&gt;
                                      &lt;textarea cols="40" rows="5" style="height: 150px" type="text" required value="" class="form-control" name="input_description"
                                                id="input-1"&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="form-group"&gt;
                                      &lt;button type="button" onclick="savebook()" class="btn btn-primary shadow-primary px-5"&gt;Save&lt;/button&gt;
                                  &lt;/div&gt;
  
                              &lt;/form&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
  
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;?php
      $this-&gt;load-&gt;view('admin/comman/footerpage');
      ?&gt;
      &lt;script type="text/javascript"&gt;
  
          $('#purpose').on('change', function () {
              if (this.value === '1') {
                  $("#business").show();
              } else {
                  $("#business").hide();
              }
          });
  
          function savebook() {
  
              var wallpaper_title = jQuery('input[name=wallpaper_title]').val();
              if (wallpaper_title == '') {
                  toastr.error('Please enter Book Name');
                  return false;
              }
              $("#dvloader").show();
              var formData = new FormData($("#edit_video_form")[0]);
              $.ajax({
                  type: 'POST',
                  url: '&lt;?php echo base_url(); ?&gt;index.php/admin/savebook',
                  data: formData,
                  cache: false,
                  contentType: false,
                  processData: false,
                  dataType: "json",
                  success: function (resp) {
                      $("#dvloader").hide();
                      if (resp.status == '200') {
                          document.getElementById("edit_video_form").reset();
                          toastr.success(resp.msg, 'success');
                          setTimeout(function () {
                              location.reload();
                          }, 500);
                      } else {
                          toastr.error(resp.msg);
                      }
                  },
                  error: function (XMLHttpRequest, textStatus, errorThrown) {
                      $("#dvloader").hide();
                      toastr.error(errorThrown.msg, 'failed');
                  }
              });
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>here is the database code </p>
  
  <pre><code>enter code here
  
  public function savebook(){
      $input_name = $_POST['input_name'];
      $input_description = $_POST['input_description'];
      $input_price = $_POST['input_price'];
      $select_category = $_POST['select_category'];
      $select_author = $_POST['select_author'];
      $select_cost = $_POST['select_cost'];
      $is_feature = "yes";
      $b_status = "enable";
      $fa_id = $_POST['select_author'];
  
      $input_bookcover=$this-&gt;imageupload($_FILES['input_bookcover'],'input_bookcover', FCPATH . 'assets/images/book');
  
      if (isset($_FILES['input_sample_book']) &amp;&amp; !empty($_FILES['input_sample_book']['name'])) {
          $input_sample_book=$this-&gt;fileupload($_FILES['input_sample_book'],'input_sample_book', FCPATH . 'assets/images/book');
      }
  
      if (isset($_FILES['input_full_book']) &amp;&amp; !empty($_FILES['input_full_book']['name'])) {
          $input_full_book=$this-&gt;fileupload($_FILES['input_full_book'],'input_full_book', FCPATH . 'assets/images/book');
      }
  
      $data = array(
          'b_title' =&gt; $input_name,
          'b_description' =&gt; $input_description,
          'is_paid' =&gt; $select_cost,
          'sample_b_url' =&gt; $input_sample_book,
          'b_url' =&gt; $input_full_book,
          'b_price' =&gt; $input_price,
          'fcat_id'=&gt; $select_category,
          'b_image' =&gt; $input_bookcover,
          'is_feature' =&gt; $is_feature,
          'b_status' =&gt; $b_status,
          'fa_id' =&gt; $fa_id,
          'b_date' =&gt; date('Y-m-d h:i:s')
      );
  
      $res_id=$this-&gt;Adminmodel-&gt;add_book($data);
  
      if($res_id){
          $res=array('status'=&gt;'200','msg'=&gt;'Book added successfully.','id'=&gt;$res_id);
          echo json_encode($res);exit;
      }else{
          $res=array('status'=&gt;'400','msg'=&gt;'fail');
          echo json_encode($res);exit;
      }
  }   
  </code></pre>