title: Not inserting into Database in CODEIGNITER Mysql
body: <p>Not inserting..Any Suggestions??
  DB Driver: mysqli
  using Codeigniter.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function add_quote()
      {
  
          $this-&gt;form_validation-&gt;set_rules('invoice_no', $this-&gt;lang-&gt;line("invoice_no"));
          $this-&gt;form_validation-&gt;set_rules('date', $this-&gt;lang-&gt;line("date"), 'required');
          $this-&gt;form_validation-&gt;set_rules('customer', $this-&gt;lang-&gt;line("customer"), 'required');
          if($this-&gt;input-&gt;post('customer') == 'new') {
              $this-&gt;form_validation-&gt;set_rules('state', $this-&gt;lang-&gt;line("state"));
              $this-&gt;form_validation-&gt;set_rules('gstin', $this-&gt;lang-&gt;line("gstin"));
              $this-&gt;form_validation-&gt;set_rules('company', $this-&gt;lang-&gt;line("company")." ".$this-&gt;lang-&gt;line("name"), 'required');
              $this-&gt;form_validation-&gt;set_rules('email', $this-&gt;lang-&gt;line("customer")." ".$this-&gt;lang-&gt;line("email_address"), 'required|valid_email|is_unique[customers.email]');
              $this-&gt;form_validation-&gt;set_rules('phone', $this-&gt;lang-&gt;line("phone"), 'required|min_length[6]|max_length[16]');
          }
  
          if ($this-&gt;form_validation-&gt;run() == true) {
  
              print_r("helo World");
              exit;
  
              $form = $this-&gt;sales_model-&gt;process_form();
              $customer_data = $form['customer_data'];
              $products = $form['products'];
              $data = $form['data'];
              $dum = 'Q-'.$data['reference_no'];
              $data['reference_no'] = $dum;
              //unset($data['due_date'], $data['recurring']);
  
               //echo '&lt;pre /&gt;'; var_dump($data); var_dump($products); die();
          }
  
          //$data1 = array('reference_no' =&gt; 1);
          //$this-&gt;db-&gt;insert('customers',$data1);
          if ($this-&gt;form_validation-&gt;run() == true &amp;&amp; $this-&gt;sales_model-&gt;addQuote($data, $products, $customer_data)) {
  
              $this-&gt;session-&gt;set_flashdata('message', $this-&gt;lang-&gt;line("quote_added"));
              redirect("sales/quotes");
  
          } else {
  
              $this-&gt;data['error'] = (validation_errors() ? validation_errors() : $this-&gt;session-&gt;flashdata('error'));
              $this-&gt;data['inv'] = false;
              $this-&gt;data['q'] = true;
              $this-&gt;data['customers'] = $this-&gt;sales_model-&gt;getAllCustomers();
              $this-&gt;data['tax_rates'] = $this-&gt;sales_model-&gt;getAllTaxRates();
              $this-&gt;data['companies'] = $this-&gt;sales_model-&gt;getAllCompanies();
              $this-&gt;data['page_title'] = $this-&gt;lang-&gt;line("new_quote");
              $this-&gt;page_construct('sales/add_quote', $this-&gt;data);
  
          }
      }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public function addQuote($data = array(), $items = array(), $customer = array()) {
  
          if(!empty($customer)) {
  
              if($this-&gt;db-&gt;insert('customers', $customer)) {
                  $customer_id = $this-&gt;db-&gt;insert_id();
              }
              $data['customer_id'] = $customer_id;
          }
  
          if($this-&gt;db-&gt;insert('quotes', $data)) { //Not inserted so Not enter into this loop
  
              $quote_id = $this-&gt;db-&gt;insert_id();
  
              foreach ($items as $item) {
                  $item['quote_id'] = $quote_id;
                  $this-&gt;db-&gt;insert('quote_items', $item);
              }
              return true;
          }
          else{
              print_r("not inserted DATA");
              exit;
          }
  
          return false;
      }
  </code></pre>
  
  <p><strong>Array Result:(Print_r($data))</strong></p>
  
  <blockquote>
    <p>Array ( [reference_no] => Q-SMGP/17-18/000003 [company_id] => 1
    [company_name] => SMGP [vehicle_no] => dfg [date_time_supply] =>
    2017-07-15 12:17 [place_supply] => sdafsd [consignee_name] => safsdaf
    [consignee_address] => sdfsdaf [consignee_gstin] => 6556
    [consignee_state] => sdfsa [consignee_state_code] => sdafaf [date] =>
    2017-07-15 12:17 [due_date] => [expiry_date] => 2017-07-15 [user] => 1
    [user_id] => 1 [customer_id] => 3 [customer_name] => Seed Arise
    [total_tax] => 28.0000 [total] => 2100 [grand_total] => 2600.0000
    [status] => ordered [shipping] => 500.00 [note] => )</p>
  </blockquote>