Welcome Guest, Not a member yet? Register   Sign In
Database Problem when register some fields...
#1

[eluser]Unknown[/eluser]
Hi Guys,

I am new on codeIgniter... I am trying to do some simple CRUD but I am getting an database issue. I tried to google it for 2 hours and did not found the solution.

Here is my model

Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');

class Crud_model extends CI_Model {

public function do_insert($dados) {
   if ($dados =! NULL) :
    $this->db->insert('curso_ci', $dados);
   endif;
}

}


here is my create function on my controller

Code:
public function create() {
  //validacao do from
  $this -> form_validation -> set_rules('nome', 'NOME', 'trim|required|alpha|max_length(50)|ucwords');
  $this -> form_validation -> set_rules('email', 'EMAIL', 'trim|required|max_length(50)|strtolower|valid_email|is_unique[curso_ci.login]');
  $this -> form_validation -> set_rules('login', 'LOGIN', 'trim|required|max_length(25)|strtolower|is_unique[curso_ci.login]');
  $this -> form_validation -> set_rules('senha', 'SENHA', 'trim|required|strtolower');
  $this -> form_validation -> set_message('matches', 'O campo %s esta diferente do campo %s');
  $this -> form_validation -> set_rules('senha2', 'REPITA SENHA', 'trim|required|strtolower|matches[senha]');
  
  if ($this -> form_validation -> run() == TRUE) :
   $dados = elements(array('nome','email','login','senha'), $this->input->post());
   $this->load->model('crud_model');
   $this->crud_model->do_insert($dados);
  endif;

  $dados = array("titulo" => 'CRUD » Create', "tela" => 'create', );

  $this -> load -> view('crud', $dados);

}



The erro I get when I tried to register the fields on my database is the follwoing


Error Number: 1054

Unknown column '1' in 'field list'

INSERT INTO `curso_ci` (`1`) VALUES ('')

Filename: C:\xampp\htdocs\ci\system\database\DB_driver.php

Line Number: 330




Theme © iAndrew 2016 - Forum software by © MyBB