title: Can not insert data in Mysql using codeigniter
body: <p>I can not insert data into mysql because of database error 1048.I have been searching from almost 1 week, but i couldn't find any solution. please help me. Here is all the stuff...</p>
  
  <p>controller users.php:</p>
  
  <pre><code>&lt;?php
  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class Users extends CI_Controller 
  {
      function __construct()
      {
          parent::__construct();
          #$this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;model('users_model');
      }
  
      public function index()
      {
          $data['user_list'] = $this-&gt;users_model-&gt;get_all_users();
          $this-&gt;load-&gt;view('show_users', $data);
      }
  
      public function add_form()
      {
          $this-&gt;load-&gt;view('insert');
      }
  
      public function insert_new_user()
      {
          $udata['Username'] = $this-&gt;input-&gt;post('name');
          $udata['Email-Id'] = $this-&gt;input-&gt;post('email');
          $udata['Address'] = $this-&gt;input-&gt;post('address');
          $udata['Mobile'] = $this-&gt;input-&gt;post('mobile');
          $res = $this-&gt;users_model-&gt;insert_users_to_db($udata);
  
          if($res)
          {
              header("location: http://localhost/crudcode/index.php/users_model/insert_users_to_db");
          }
          else
          {
              echo "Hello";
          }
      }
  
  }
  </code></pre>
  
  <p>Model  users_model.php:</p>
  
  <pre><code>&lt;?php
  
  class Users_model extends CI_Model 
  {
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;database();
      }
  
      public function get_all_users()
      {
          $query = $this-&gt;db-&gt;get('users');
          return $query-&gt;result();
      }
  
      public function insert_users_to_db($udata)
      {
          return $this-&gt;db-&gt;insert('users', $udata);
      }
  
      public function getById($id)
      {
          $query = $this-&gt;db-&gt;get_where('users',array('id'=&gt;$id));
          return $query-&gt;row_array();
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>view  insert.php:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt;CI Insert Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="post" action="localhost/crudcode/index.php/users/insert_new_user"&gt;
  &lt;table width="400" border="0" cellpadding="5"&gt;
  
      &lt;tr&gt;
          &lt;th width="213" align="right" scope="row"&gt;Enter your username&lt;/th&gt;
          &lt;td width="161"&gt;&lt;input type="text" name="name" size="20" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;th align="right" scope="row"&gt;Enter your email&lt;/th&gt;
          &lt;td&gt;&lt;input type="text" name="email" size="20" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;th align="right" scope="row"&gt;Enter your Mobile&lt;/th&gt;
          &lt;td&gt;&lt;input type="text" name="mobile" size="20" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;th align="right" scope="row"&gt;Enter Your Address&lt;/th&gt;
          &lt;td&gt;&lt;textarea name="address" rows="5" cols="20"&gt;&lt;/textarea&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;th align="right" scope="row"&gt;&amp;nbsp;&lt;/th&gt;
          &lt;td&gt;&lt;input type="submit" name="submit" value="Send" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/o75W7.png" rel="nofollow">Here is the error</a></p>