Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter: Unknown column 'xxx' in 'field list'
    text
    copied!<p>Here's my exported BD table:</p> <pre><code>CREATE TABLE `hta_users` ( `id` int(11) NOT NULL auto_increment, `nombre` varchar(100) collate utf8_spanish_ci NOT NULL, `apellidos` varchar(255) collate utf8_spanish_ci NOT NULL, `nif` varchar(10) collate utf8_spanish_ci NOT NULL, `direccion` varchar(255) collate utf8_spanish_ci NOT NULL, `cp` varchar(5) collate utf8_spanish_ci NOT NULL, `poblacion` varchar(255) collate utf8_spanish_ci NOT NULL, `provincia` int(2) NOT NULL, `telefono` varchar(9) collate utf8_spanish_ci NOT NULL, `edad` int(3) NOT NULL, `retribucion` int(1) NOT NULL, `entidad` varchar(4) collate utf8_spanish_ci NOT NULL, `oficina` varchar(4) collate utf8_spanish_ci NOT NULL, `dc` varchar(2) collate utf8_spanish_ci NOT NULL, `cc` varchar(10) collate utf8_spanish_ci NOT NULL, `centro` varchar(255) collate utf8_spanish_ci NOT NULL, `email` varchar(255) collate utf8_spanish_ci NOT NULL, `especialidad` int(2) NOT NULL, `parent` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `nif` (`nif`,`email`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=1 ; </code></pre> <p>Here's my model function:</p> <pre><code>function add_user( $nombre, $apellidos, $nif, $direccion, $cp, $poblacion, $provincia, $telefono, $edad, $retribucion, $cc_entidad, $cc_oficina, $cc_dc, $cc_cc, $centro, $email, $especialidad, $parent ) { $tbl = $this-&gt;db-&gt;dbprefix('users'); if( $retribucion == 1 ) { $sql = array( 'nombre' =&gt; $nombre, 'apellidos' =&gt; $apellidos, 'nif' =&gt; $nif, 'direccion' =&gt; $this-&gt;db-&gt;escape($direccion), 'cp' =&gt; $cp, 'poblacion' =&gt; $poblacion, 'provincia' =&gt; $provincia, 'telefono' =&gt; $telefono, 'edad' =&gt; $edad, 'retribucion' =&gt; $retribucion, 'entidad' =&gt; $cc_entidad, 'oficina' =&gt; $cc_oficina, 'dc' =&gt; $cc_dc, 'cc' =&gt; $cc_cc, 'centro' =&gt; $centro, 'email' =&gt; $email, 'especialidad' =&gt; $especialidad, 'parent' =&gt; $parent ); } else { $sql = array( 'nombre' =&gt; $nombre, 'apellidos' =&gt; $apellidos, 'nif' =&gt; $nif, 'direccion' =&gt; $this-&gt;db-&gt;escape($direccion), 'cp' =&gt; $cp, 'poblacion' =&gt; $poblacion, 'provincia' =&gt; $provincia, 'telefono' =&gt; $telefono, 'edad' =&gt; $edad, 'retribucion' =&gt; $retribucion, 'centro' =&gt; $centro, 'email' =&gt; $email, 'especialidad' =&gt; $especialidad, 'parent' =&gt; $parent ); } $this-&gt;db-&gt;insert($tbl, $sql); if( $this-&gt;db-&gt;affected_rows() == 0 ) return false; else return true; } </code></pre> <p>Here's my controller piece of code:</p> <pre><code>if( $this-&gt;users-&gt;add_user($nombre, $apellidos, $nif, $direccion, $cp, $poblacion, $provincia, $telefono, $edad, $retribucion, $cc_entidad, $cc_oficina, $cc_dc, $cc_cc, $centro, $email, $especialidad, $parent) ) { $data['form_error'] = 'Se ha añadido al usuario.'; $data['module'] = 'registro'; $this-&gt;load-&gt;view('template', $data); } else { $data['form_error'] = 'Se ha producido un error al agregar al usuario a la BD.'; $data['module'] = 'registro'; $this-&gt;load-&gt;view('template', $data); } </code></pre> <p>And that's the error i'm getting:</p> <pre><code>A Database Error Occurred Error Number: 1054 Unknown column 'entidad' in 'field list' INSERT INTO `hta_users` (`nombre`, `apellidos`, `nif`, `direccion`, `cp`, `poblacion`, `provincia`, `telefono`, `edad`, `retribucion`, `entidad`, `oficina`, `dc`, `cc`, `centro`, `email`, `especialidad`, `parent`) VALUES ('nombre', 'apellidos', '12345678Q', '\'elm st 666\'', '08008', 'Barcelona', '1', '666555666', '2', 1, '9999', '9999', '99', '9999999999', 'home', 'email@domain.com', '1', '0') </code></pre> <p>Can someone help? I don't know what's happening nor why... :/</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload