title: Error: 1265 SQLSTATE: 01000 (WARN_DATA_TRUNCATED)
body: <p>First of all, sorry if I wrote some nosense, but I don't usually write in English, and it's a little hard to me.
  Second, I'm a newbie as programmer, so it's probably my question is too easy and obvius (I promise I tried to find the answer before ask here).</p>
  
  <p>Well, I want to practice with php and mysql, so I want to make a bbdd and a GUI to control it. Here are the code where I have the problem:</p>
  
  <p>MySql (v5.6.12):</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `personaje` (
  
  `id_personaje` int(3) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(30) NOT NULL,
  `servidor` varchar(25) NOT NULL,
  `nivel` int(3) NOT NULL,
  `faccion` varchar(10) NOT NULL,
  `clase` varchar(25) NOT NULL,
  `raza` char(30) NOT NULL,
  `profesion1` varchar(20) NOT NULL,
  `nivel1` int(4) NOT NULL,
  `profesion2` varchar(20) NOT NULL,
  `nivel2` int(4) NOT NULL,
  `nivel_coc` int(4) NOT NULL,
  `nivel_pes` int(4) NOT NULL,
  `nivel_arqu` int(4) NOT NULL,
  `nivel_prim` int(4) NOT NULL,
  
  PRIMARY KEY (`id_personaje`),
  UNIQUE KEY `raza` (`raza`),
  UNIQUE KEY `clase` (`clase`),
  UNIQUE KEY `prof1` (`profesion1`),
  UNIQUE KEY `prof2` (`profesion2`),
  UNIQUE KEY `faccion` (`faccion`)
  ) 
  ENGINE=InnoDB 
  </code></pre>
  
  <p>PHP(v5.4.12):</p>
  
  <pre><code>    &lt;?php
  
  
      //Recoger los datos que llegan
  
      $nombre = $_POST['nombreChar'];
      $raza = $_POST['razaChar'];
      $clase = $_POST['claseChar'];
      $servidor = $_POST['servidorChar'];
      $faccion = $_POST['faccionChar'];
      $nivel = $_POST['nivelChar'];
      settype($nivel,"int");
      $prof1 = $_POST['prof1Char'];
      $lvlpr1 = $_POST['lvlpr1Char'];
      $prof2 = $_POST['prof2Char'];
      $lvlpr2 = $_POST['lvlpr2Char'];
      $nivel_coc = $_POST['nivel_cocChar'];
      $nivel_arqu = $_POST['nivel_arquChar'];
      $nivel_pes = $_POST['nivel_pesChar'];
      $nivel_prim = $_POST['nivel_primChar'];
      $muestra = gettype($nivel);
  
       //Conectandonos con la base de datos
     $conexion = mysql_connect(/* ... */);
      mysql_select_db (/* ... */, $conexion) OR die ("No se puede conectar");
  
      //Comprobar que no haya otro personaje repetido
     /* $Consulta_per = "SELECT nombre, servidor FROM personaje WHERE nombre =
          '".$nombre."' &amp;&amp; servidor = '".$servidor."'";
      $busqueda = mysql_query($Consulta_per,$conexion) or die ("Error en busqueda " . mysql_error());       
      if (!$busqueda)
          */
      $res = mysql_query("INSERT INTO personaje (nombre, servidor, nivel, faccion, 
          clase, raza, profesion1, nivel1, profesion2, nivel2, nivel_coc, 
          nivel_pes, nivel_arqu, nivel_prim) VALUE ('$nombre','$servidor',
              '$nivel,','$faccion','$clase','$raza','$prof1','$lvlpr1',
                  '$prof2','$lvlpr2','$nivel_coc','$nivel_pes','$nivel_arqu',
                      '$nivel_prim')",$conexion)
      or die ("No se pudo insertar " . mysql_error() ." ". $nivel . $muestra );// this line show the error
      echo "Insertado con exito";
      mysql_close($conexion);
  
      ?&gt;
  </code></pre>
  
  <p>The form that comes is:</p>
  
  <pre><code>    &lt;FORM method="POST" action="crear-personaje.php"&gt;
          Nombre &lt;INPUT type="text" name="nombreChar" id="nombreChar" value="Nombre"&gt;&lt;/br&gt;
          Raza &lt;INPUT type="text" name="razaChar" id="razaChar" value="Raza"&gt;&lt;/br&gt;
          Facción &lt;INPUT type="text" name="faccionChar" id="faccionChar" value="Facción"&gt;&lt;/br&gt;
          Clase &lt;INPUT type="text" name="claseChar" id="claseChar" value="Clase"&gt;&lt;/br&gt;
          Servidor &lt;INPUT type="text" name="servidorChar" id="servidorChar" value="Servidor"&gt;&lt;/br&gt;
          Nivel &lt;INPUT type="number" name="nivelChar" id="nivelChar" value="1"&gt;&lt;/br&gt;
          Profesión 1 &lt;INPUT type="text" name="prof1Char" id="prof1Char" value="Profesion1"&gt;&lt;/br&gt;
          Nivel de profesión 1 &lt;INPUT type="text" name="lvlpr1Char" id="lvlpr1Char" value="1"&gt;&lt;/br&gt;
          Profesion 2 &lt;INPUT type="text" name="prof2Char" id="prof2Char" value="Profesion2"&gt;&lt;/br&gt;
          Nivel de profesion 2 &lt;INPUT type="text" name="lvlpr2Char" id="lvlpr2Char" value="1"&gt;&lt;/br&gt;
          Nivel cocina&lt;INPUT type="text" name="nivel_cocChar" id="nivel_cocChar" value="1"&gt;&lt;/br&gt;
          Nivel pesca&lt;INPUT type="text" name="nivel_pesChar" id="nivel_pesChar" value="1"&gt;&lt;/br&gt;
          Nivel primeros auxilios&lt;INPUT type="text" name="nivel_primChar" id="nivel_primChar" value="1"&gt;&lt;/br&gt;
          Nivel arqueología&lt;INPUT type="text" name="nivel_arquChar" id="nivel_arquChar" value="1"&gt;&lt;/br&gt;
  
          &lt;INPUT type="submit" NAME="enviar" VALUE="Dar de alta!" id="enviar"&gt;
  
      &lt;/FORM&gt;
  </code></pre>
  
  <p>Apache version 2.4.4</p>
  
  <p>Everything must be ok, but... no. When I tried to insert a integer value (like 87 or 1) in the "nivel" field, mysql give me the next error:</p>
  
  <p><code>"No se pudo insertar Data truncated for column 'nivel' at row 1 1integer"</code>, like the comment I wrote in the code.</p>
  
  <p>("No se pudo insertar" means "Cannot insert").</p>
  
  <p>As you can see, I forced the variable $nivel as integer, and PHP recognice correctly (that's the reason I put $nivel and $muestra in the die sentence). I tried change the type "nivel" variable from int (3) to Varchar (3) in MySql, and let me introduce the character, but... I preffer use the type int (the level of a character ever is a integer, obviusly).</p>
  
  <p>Anyone know why MySql give me this error? What can I do to solve this? </p>
  
  <p>Thanks for help!</p>