Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/09/2013, 19:16
xsaboteadorx
 
Fecha de Ingreso: junio-2013
Ubicación: Bs aS
Mensajes: 20
Antigüedad: 10 años, 10 meses
Puntos: 0
Error al registrar un formulario en php

Código PHP:
Ver original
  1. <?
  2.     include "../extras/php/conexion.php";
  3.     include "../extras/php/basico.php";
  4.    
  5.     /*verificamos si las variables se envian*/
  6.     if(empty($_POST['unidad']) || empty($_POST['superior']) || empty($_POST['abreviatura']) || empty($_POST['descripcion']) || empty($_POST['desc_ant']) || empty($_POST['desc_hist']) || empty($_POST['desc_radio']) || empty($_POST['cod_guarnicion']) || empty($_POST['cod_desfa']) || empty($_POST['calle']) || empty($_POST['casa'])|| empty($_POST['dpto']) || empty($_POST['cod_postal']) || empty($_POST['localidad']) || empty($_POST['cod_provincia']) || empty($_POST['telex']) || empty($_POST['telefono']) || empty($_POST['x']) || empty($_POST['y']) || empty($_POST['nivel']) || empty($_POST['cuenta']) || empty($_POST['org_comun']) || empty($_POST['fte_recluta']) || empty($_POST['bal']) || empty($_POST['escuela']) || empty($_POST['grupo']) || empty($_POST['oficiales']) || empty($_POST['suboficiales']) || empty($_POST['estado']) || empty($_POST['cod_uniorig']) || empty($_POST['activa']) || empty($_POST['localizacion']) || empty($_POST['cod_mov']) || empty($_POST['nro_mov']) || empty($_POST['fec_mov']) || empty($_POST['cod_ope']) || empty($_POST['fec_ope']) || empty($_POST['correo']) || empty($_POST['sitelpar']) || empty($_POST['equipo1']) || empty($_POST['equipo2']) || empty($_POST['equipo3']) || empty($_POST['coef_zona']) || empty($_POST['ala']) || empty($_POST['dela']) || empty($_POST['orden_resol']) || empty($_POST['cod_grupo']) || empty($_POST['cod_subgrupo']) || empty($_POST['programa']) || empty($_POST['zona']) || empty($_POST['actividad']) || empty($_POST['bsc_nivel']) || empty($_POST['depend']) || empty($_POST['nc']) || empty($_POST['ema']) || empty($_POST['cjrm']) || empty($_POST['recluta']) || empty($_POST['nodo']) || empty($_POST['acceso_internet'])){
  7.         echo "Usted no a llenado todos los campos";
  8.         exit;
  9.     }
  10.    
  11.     /*obtenemos el ide mayor*/
  12.     $sql = "select cod_unidad from unidades order by cod_unidad desc limit 1";
  13.     $per = mysql_query($sql);
  14.     $rs_per = mysql_fetch_assoc($per);
  15.    
  16.     /*insertamos el nuevo registro*/
  17.     $cod_unidad = $rs_per['cod_unidad'] + 1;
  18.  
  19.     $sql = sprintf("INSERT INTO 'unidades' VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s' now());",
  20.         fn_filtro(substr($unidad)),
  21.         fn_filtro(substr ($superior)),
  22.         fn_filtro(substr($_POST['abreviatura'], 0, 66)),
  23.         fn_filtro(substr($_POST['descripcion'], 0, 153)),
  24.         fn_filtro(substr($_POST['desc_ant'], 0, 115)),
  25.         fn_filtro(substr($_POST['desc_hist'], 0, 153))
  26.         fn_filtro(substr($_POST['desc_radio'], 0, 153)),
  27.         fn_filtro(substr($_POST['cod_guarnicion'], 0, 2)),
  28.         fn_filtro(substr($_POST['cod_desfa'], 0, 1)),
  29.         fn_filtro(substr($_POST['calle'], 0, 66)),
  30.         fn_filtro(substr($_POST['casa'], 0, 5)),
  31.         fn_filtro(substr($_POST['dpto'], 0, 8)),
  32.         fn_filtro(substr($_POST['cod_postal'], 0, 5)),
  33.         fn_filtro(substr($_POST['localidad'], 0, 47)),
  34.         fn_filtro(substr($_POST['cod_provincia'], 0, 1)),
  35.         fn_filtro(substr($_POST['telex'], 0, 17)),
  36.         fn_filtro(substr($_POST['telefono'], 0, 30)),
  37.         fn_filtro(substr($_POST['x'], 0, 50)),
  38.         fn_filtro(substr($_POST['y'], 0, 50)),
  39.         fn_filtro(substr($_POST['nivel'], 0, 1)),
  40.         fn_filtro(substr($_POST['cuenta'], 0, 50)),
  41.         fn_filtro(substr($_POST['org_comun'], 0, 1)),
  42.         fn_filtro(substr($_POST['fte_recluta'], 0, 1)),
  43.         fn_filtro(substr($_POST['bal'], 0, 1)),
  44.         fn_filtro(substr($_POST['escuela'], 0, 1)),
  45.         fn_filtro(substr($_POST['grupo'], 0, 4)),
  46.         fn_filtro(substr($_POST['oficiales'], 0, 50)),
  47.         fn_filtro(substr($_POST['suboficiales'], 0, 50)),
  48.         fn_filtro(substr($_POST['estado'], 0, 1)),
  49.         fn_filtro(substr($_POST['cod_uniorig'], 0, 5)),
  50.         fn_filtro(substr($_POST['activa'], 0, 1)),
  51.         fn_filtro(substr($_POST['localizacion'], 0, 5)),
  52.         fn_filtro(substr($_POST['cod_mov'], 0, 18)),
  53.         fn_filtro(substr($_POST['nro_mov'], 0, 50)),
  54.         fn_filtro(substr($_POST['fec_mov'], 0, 9)),
  55.         fn_filtro(substr($_POST['cod_ope'], 0, 50)),
  56.         fn_filtro(substr($_POST['fec_ope'], 0, 20)),
  57.         fn_filtro(substr($_POST['correo'], 0, 20)),
  58.         fn_filtro(substr($_POST['sitelpar'], 0, 3)),
  59.         fn_filtro(substr($_POST['equipo1'], 0, 3)),
  60.         fn_filtro(substr($_POST['equipo2'], 0, 3)),
  61.         fn_filtro(substr($_POST['equipo3'], 0, 50)),
  62.         fn_filtro(substr($_POST['coef_zona'], 0, 5)),
  63.         fn_filtro(substr($_POST['ala'], 0, 5)),
  64.         fn_filtro(substr($_POST['dela'], 0, 10)),
  65.         fn_filtro(substr($_POST['orden_resol'], 0, 50)),
  66.         fn_filtro(substr($_POST['cod_grupo'], 0, 7)),
  67.         fn_filtro(substr($_POST['cod_subgrupo'], 0, 50)),
  68.         fn_filtro(substr($_POST['programa'], 0, 12)),
  69.         fn_filtro(substr($_POST['zona'], 0, 50)),
  70.         fn_filtro(substr($_POST['actividad'], 0, 50)),
  71.         fn_filtro(substr($_POST['bsc_nivel'], 0, 143)),
  72.         fn_filtro(substr($_POST['depend'], 0, 1)),
  73.         fn_filtro(substr($_POST['nc'], 0, 10)),
  74.         fn_filtro(substr($_POST['ema'], 0, 10)),
  75.         fn_filtro(substr($_POST['cjrm'], 0, 10)),
  76.         fn_filtro(substr($_POST['recluta'], 0, 1)),
  77.         fn_filtro(substr($_POST['nodo'], 0, 50)),
  78.         fn_filtro(substr($_POST['acceso_internet'], 0, 1))
  79.     );
  80.  
  81.     if(!mysql_query($sql))
  82.         echo "Error al insertar a la nueva persona:\n$sql";
  83.  
  84.     exit;
  85. ?>


Cuando doy a registrar me tira este error:

<br />
<font size='1'><table class='xdebug-error xe-parse-error xe-scream' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SCREAM: Error suppression ignored for</th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Parse error: syntax error, unexpected 'fn_filtro' (T_STRING) in C:\wamp\www\prueba\persona\ajax_agregar.php on line <i>26</i></th></tr>
</table></font>


P/D: Toda son variable de tipo varchar y como mi primary key es alfanumerico (unidad) y no tiene un auto incrementar.

Última edición por xsaboteadorx; 19/09/2013 a las 19:30