title: Database help needed i'm stumped
body: <p>I recently downloaded some software made with the codeigniter framework after following the install instructions, I ran the website on localhost, which loads up but as soon as I goto register a new member it gives me the following error. I'm brand new to all of this so what may seem trivial to you probably won't to me just a heads up.</p>
  
  <blockquote>
    <p>Error Number: 1054 Unknown column 'activation_hash' in 'field list'
    INSERT INTO `bw_users` (`password`, `location`, `register_time`,
    `salt`, `activation_hash`, `activation_id`, `email_address`,
    `email_activated`, `user_hash`, `user_name`, `user_role`,
    `public_key`, `private_key`, `private_key_salt`, `wallet_salt`,
    `local_currency`) VALUES
    $2a$10$51GaLf4o644Rb/FxR8Os9enxWuop1V.haISOHzinT1Tq674.5SaXm', '224',
    1454533259, '$2a$10$51GaLf4o644Rb/FxR8Os9hA2gGDxVQ==',
    'f0a57fb24bcda7bd87e26bc9bafb71ee', 'ae7522de65812b', '', '1',
    '2eb1a2c0b086bf044a80',</p>
    
    <p>Filename: models/Users_model.php</p>
    
    <p>Line Number: 37</p>
  </blockquote>
  
  <p>I pulled up the Users_model line 37 and the code surrounding it</p>
  
  <pre><code>public function add($data, $token_info = NULL)
  {
      $ret = $this-&gt;db-&gt;insert('users', $data) == TRUE;   &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;  This is line 37
      if ($token_info !== null)
          $this-&gt;delete_registration_token($token_info['id']);
  
      return $ret;
  }
  </code></pre>
  
  <p>I then checked the rest of the code for activation_hash and the only place I could see it was towards the bottom of the users_model.php, it is as follows.</p>
  
  <pre><code>public function attempt_email_activation($identifier, $subject, $activation_hash)
  {
      $q = $this-&gt;db-&gt;select('id, email_activated')-&gt;get_where('users', array($identifier =&gt; $subject, 'activation_hash' =&gt; $activation_hash));
      if ($q-&gt;num_rows() &gt; 0) {
          $row = $q-&gt;row_array();
          if ($row['email_activated'] == '1') {
              return 'activated';
          } else {
              $this-&gt;_set_activated_email($row['id']);
              return TRUE;
          }
      }
      return FALSE;
  }
  </code></pre>
  
  <p>This is the bw_users part of my sql database, I can post the whole database dump if needed.</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `bw_users` (
    `id` int(9) NOT NULL AUTO_INCREMENT,
    `banned` enum('0','1') DEFAULT '0',
    `block_non_pgp` enum('0','1') DEFAULT '0',
    `entry_paid` enum('0','1') DEFAULT '0',
    `force_pgp_messages` enum('0','1') DEFAULT '0',
    `location` int(3) NOT NULL,
    `login_time` int(20) NOT NULL,
    `display_login_time` enum('0','1') DEFAULT '0',
    `password` varchar(128) NOT NULL,
    `public_key` blob NOT NULL,
    `private_key` blob NOT NULL,
    `private_key_salt` varchar(64) NOT NULL,
    `register_time` int(20) NOT NULL,
    `salt` varchar(128) NOT NULL,
    `wallet_salt` varchar(128) NOT NULL,
    `user_hash` varchar(25) NOT NULL,
    `user_name` varchar(40) NOT NULL,
    `user_role` enum('Buyer','Vendor','Admin') NOT NULL,
    `local_currency` int(11) NOT NULL,
    `completed_order_count` int(9)  DEFAULT '0',
    `totp_secret` varchar(25),
    `totp_two_factor` enum('0','1') DEFAULT '0',
    `pgp_two_factor` enum('0','1') DEFAULT '0',
    PRIMARY KEY (`id`),
    UNIQUE KEY `user_hash` (`user_hash`,`user_name`),
    KEY `user_name`  (`user_name`,`user_hash`,`banned`,`entry_paid`,`register_time`,`user_role`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
  
  INSERT INTO `bw_users` (`banned`, `block_non_pgp`, `entry_paid`,     `force_pgp_messages`, `location`, `login_time`, `display_login_time`, `password`, `public_key`, `private_key`, `private_key_salt`, `register_time`, `salt`, `pgp_two_factor`, `user_hash`, `user_name`, `user_role`, `local_currency`, `completed_order_count`, `totp_two_factor`, `totp_secret`) VALUES
  ('0', '0', '1', '0', 1, 0, '0', '%PASSWORD%', '%PUBLIC_KEY%', '%PRIVATE_KEY%', '%PRIVATE_KEY_SALT%', '%REGISTER_TIME%', '%SALT%', '0', '%USER_HASH%', 'admin', 'Admin', 0, 0, '0', '');
  </code></pre>
  
  <p>Can someone please tell me what I need to do, to remove this error and be able to register users, i've been trying to figure this out all day and it's driving me crazy. Thank you for any help.</p>
  
  <p>EDIT ----------------------------------------</p>
  
  <p>Thanks for the replys so far, I have modified the tables as follows with the information provided by @Vũ Tuấn Anh</p>
  
  <p>ALTER TABLE bw_users
  ADD COLUMN <code>activation_hash</code> VARCHAR(128), 
  ADD COLUMN <code>activation_id</code> VARCHAR(128), 
  ADD COLUMN <code>email_address</code> VARCHAR(64),<br>
  ADD COLUMN <code>email_activated</code> SMALLINT(4);</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `bw_users` (
    `id` int(9) NOT NULL AUTO_INCREMENT,
    `banned` enum('0','1') DEFAULT '0',
    `block_non_pgp` enum('0','1') DEFAULT '0',
    `entry_paid` enum('0','1') DEFAULT '0',
    `force_pgp_messages` enum('0','1') DEFAULT '0',
    `location` int(3) NOT NULL,
    `login_time` int(20) NOT NULL,
    `display_login_time` enum('0','1') DEFAULT '0',
    `password` varchar(128) NOT NULL,
    `public_key` blob NOT NULL,
    `private_key` blob NOT NULL,
    `private_key_salt` varchar(64) NOT NULL,
    `register_time` int(20) NOT NULL,
    `salt` varchar(128) NOT NULL,
    `wallet_salt` varchar(128) NOT NULL,
    `user_hash` varchar(25) NOT NULL,
    `user_name` varchar(40) NOT NULL,
    `user_role` enum('Buyer','Vendor','Admin') NOT NULL,
    `local_currency` int(11) NOT NULL,
    `completed_order_count` int(9)  DEFAULT '0',
    `totp_secret` varchar(25),
    `totp_two_factor` enum('0','1') DEFAULT '0',
    `pgp_two_factor` enum('0','1') DEFAULT '0',
    'activation_hash' varchar(128),
    'activation_id' varchar(128),
    'email address' varchar(64),
    'email_activated' smallint(4),
    PRIMARY KEY (`id`),
    UNIQUE KEY `user_hash` (`user_hash`,`user_name`),
    KEY `user_name` (`user_name`,`user_hash`,`banned`,`entry_paid`,`register_time`,`user_role`, 'activation_has', 'activation_id', 'email_address', 'email_activated')
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
  
  INSERT INTO `bw_users` (`banned`, `block_non_pgp`, `entry_paid`, `force_pgp_messages`, `location`, `login_time`, `display_login_time`, `password`, `public_key`, `private_key`, `private_key_salt`, `register_time`, `salt`, `pgp_two_factor`, `user_hash`, `user_name`, `user_role`, `local_currency`, `completed_order_count`, `totp_two_factor`, `totp_secret`, 'activation_hash', 'activation_id', 'email_address', 'email_activated') VALUES
  ('0', '0', '1', '0', 1, 0, '0', '%PASSWORD%', '%PUBLIC_KEY%', '%PRIVATE_KEY%', '%PRIVATE_KEY_SALT%', '%REGISTER_TIME%', '%SALT%', '0', '%USER_HASH%', 'admin', 'Admin', 0, 0, '0', '');
  </code></pre>
  
  <p>The problem now is when I goto add the database again, it is saying there is a syntax error and it won't add the new lines, what have I done wrong here? </p>
  
  <p>At the bottom were I also put them into the insert into code, do I need to move them or any of them to the Primary Key, Unique Key or Key line instead? </p>