title: Codeigniter: "Error 1048 Column 'customer_id' cannot be null" Why am I getting this error?
body: <pre><code>INSERT INTO `dance_payment` (`customer_id`, `firstname`, `date_of_joining`, `month_of_payment`, `amount`, `receipt_number`) VALUES (NULL, 'David Noronha', '2015-08-07', 'august', '1000', 'pan001')
  </code></pre>
  
  <p>this is the "php" code</p>
  
  <pre><code>if ($this-&gt;form_validation-&gt;run() == TRUE) {
          $data = $this-&gt;payment_m-&gt;array_from_post(array('customer_id','firstname','date_of_joining','month_of_payment','amount','receipt_number') );
  
  
          // $data['date_of_joining']=date_format($data['date_of_joining'],"Y-m-d");
          $data['date_of_joining'] = flip_date($data['date_of_joining'],'SHOW');
          $nid = $this-&gt;payment_m-&gt;save($data);
  
  
          //add customer reminder
          $this-&gt;load-&gt;model('customer_course_m');
          $selected_course = $this-&gt;input-&gt;post('courses');
  
          $this-&gt;db-&gt;delete('dance_customer_course', array('customer_id' =&gt; $nid ) );
  
          //insert festival
          if(is_array($selected_course) &amp;&amp; count($selected_course) &gt; 0)
          {
              foreach ($selected_course as $kf =&gt; $vf) 
              {
                  $course_data['customer_id'] = $nid;
                  $course_data['festival_id'] = $vf;
                  $this-&gt;customer_course_m-&gt;save($course_data);
              }
          }
  
          //end of  customer reminder
          if($id)
              $this-&gt;session-&gt;set_flashdata('success','Payment details added successfully.');
          redirect('customer');
      }
  </code></pre>
  
  <p>that is the code in codeigniter, can someone please tell me what am i doing wrong or where should i check for the reason of this error, I am really bad at codeigniter, help would be really appreciated. It has been troubling me for the past 2 days, Thanks :)</p>