Foros del Web » Programando para Internet » PHP »

sos con registro a base de datos no registra

Estas en el tema de sos con registro a base de datos no registra en el foro de PHP en Foros del Web. Hola saludos nuevamente en este maravilloso foro en busca de un poco de ayuda, mi problema es el siguiente tengo un formulario el cual no ...
  #1 (permalink)  
Antiguo 20/03/2014, 21:59
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
sos con registro a base de datos no registra

Hola saludos nuevamente en este maravilloso foro en busca de un poco de ayuda, mi problema es el siguiente tengo un formulario el cual no me registra en la bd. por espero me puedan ayudar a corregir el error.

aqui el codigo

Código PHP:
Ver original
  1. <?php
  2.  
  3. <body>
  4. <?php
  5. include ("config.php");
  6. $con=mysql_connect($host,$user,$pass);
  7. if (!$con) {
  8. die('Problemas con el servidor: ' . mysql_error());
  9. }
  10. $db_selected = mysql_select_db($db,$con);
  11. if (!$db_selected) {
  12. die ('Error al conectar a la BD. : ' . mysql_error());
  13. }
  14. if (isset($_POST['guardar'])) {
  15.  
  16. $post_ano = $_POST['ano'];
  17. $post_numero = $_POST['numero'];
  18. $post_folio = $_POST['folio'];
  19. $post_fecha = $_POST['fecha'];
  20.  
  21. $post_aut = $_POST['nombre_aut'];
  22. $post_cargo = $_POST['cargo'];
  23. $post_cedula_aut = $_POST['cedula_aut'];
  24.  
  25. $post_nombre_nino = strtoupper($_POST['nombre_nino']);
  26. $post_sexo = $_POST['sexo'];
  27. $post_dia = $_POST['dia'];
  28. $post_mes = $_POST['mes'];
  29. $post_year = $_POST['year'];
  30. $post_nacido = strtoupper($_POST['nacido']);
  31. $post_hora = $_POST['hora'];
  32. $post_minutos = $_POST['minutos'];
  33. $post_am_pm = $_POST['am_pm'];
  34. $post_lugar_nino = strtoupper($_POST['lugar_nino']);
  35. $post_municipio_nino = strtoupper($_POST['municipio_nino']);
  36. $post_estado_nino = strtoupper($_POST['estado_nino']);
  37. $post_legitimo = strtoupper($_POST['legitimo']);
  38.  
  39. $post_nombre_testigo1 = strtoupper($_POST['nombre_testigo1']);
  40. $post_cedula_testigo1 = $_POST['cedula_testigo1'];
  41. $post_nombre_testigo2 = strtoupper($_POST['nombre_testigo2']);
  42. $post_cedula_testigo2 = $_POST['cedula_testigo2'];
  43.  
  44. $post_nombre_madre = strtoupper($_POST['nombre_madre']);
  45. $post_cedula_madre = $_POST['cedula_madre'];
  46. $post_edad_madre = $_POST['edad_madre'];
  47. $post_nacionalidad_madre = $_POST['nacionalidad_madre'];
  48. $post_civil_madre = $_POST['civil_madre'];
  49. $post_prof_madre = strtoupper($_POST['prof_madre']);
  50. $post_domicilio_madre = strtoupper($_POST['domicilio_madre']);
  51. $post_lugar_madre = strtoupper($_POST['lugar_madre']);
  52. $post_municipio_madre = strtoupper($_POST['municipio_madre']);
  53. $post_estado_madre = strtoupper($_POST['estado_madre']);
  54.  
  55. $post_nombre_padre = strtoupper($_POST['nombre_padre']);
  56. $post_cedula_padre = $_POST['cedula_padre'];
  57. $post_edad_padre = $_POST['edad_padre'];
  58. $post_nacionalidad_padre = $_POST['nacionalidad_padre'];
  59. $post_civil_padre = $_POST['civil_padre'];
  60. $post_prof_padre = strtoupper($_POST['prof_padre']);
  61. $post_domicilio_padre = strtoupper($_POST['domicilio_padre']);
  62. $post_lugar_padre = strtoupper($_POST['lugar_padre']);
  63. $post_municipio_padre = strtoupper($_POST['municipio_padre']);
  64. $post_estado_padre = strtoupper($_POST['estado_padre']);
  65.  
  66. $post_nombre_otro = strtoupper($_POST['nombre_otro']);
  67. $post_cedula_otro = $_POST['cedula_otro'];
  68. $post_edad_otro = $_POST['edad_otro'];
  69. $post_nacionalidad_otro = $_POST['nacionalidad_otro'];
  70. $post_civil_otro = $_POST['civil_otro'];
  71. $post_prof_otro = strtoupper($_POST['prof_otro']);
  72. $post_parentesco = strtoupper($_POST['parentesco']);
  73. $post_domicilio_otro = strtoupper($_POST['domicilio_otro']);
  74. $post_lugar_otro = strtoupper($_POST['lugar_otro']);
  75. $post_municipio_otro = strtoupper($_POST['municipio_otro']);
  76. $post_estado_otro = strtoupper($_POST['estado_otro']);
  77.  
  78. $post_usuario = $_SESSION['username'];
  79.  
  80.  
  81. $post_presentacion = $_POST['rad_presentacion'];
  82. if ($post_presentacion == 'rad_padre') {
  83.  $post_pre_padre = 1;
  84.  $post_pre_madre = 0;
  85.  $post_pre_otro = 0;
  86. }
  87.  
  88. if ($post_presentacion == 'rad_madre') {
  89.  $post_pre_padre = 0;
  90.  $post_pre_madre = 1;
  91.  $post_pre_otro = 0;
  92. }
  93.  
  94. if ($post_presentacion == 'rad_otro') {
  95.  $post_pre_padre = 0;
  96.  $post_pre_madre = 0;
  97.  $post_pre_otro = 1;
  98. }
  99.  
  100. $post_op_marginal = $_POST['rad_marginal'];
  101. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  102. if ($post_op_marginal == 'nota_si') {
  103.  $post_op_marginal_t = "SI";
  104. }
  105. if ($post_op_marginal == 'nota_no') {
  106.  $post_op_marginal_t = "NO";
  107. }
  108.  
  109. if ($post_am_pm == 'AM'){
  110.    $post_am_pm_t = 1;
  111. }
  112. if ($post_am_pm == 'PM'){
  113.    $post_am_pm_t = 2;
  114. }
  115. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  116. $post_fecha_t = "$aniox-$mesx-$diax";
  117.  
  118. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  119.  
  120. if ($post_sexo=="MASCULINO") {
  121.     $post_sexo_t = 1;
  122.     } else {
  123.     $post_sexo_t = 2;
  124. }
  125.  
  126. if ($_POST['ano'] <> "" and $_POST['numero'] <> "" and $_POST['folio'] <> "" and $_POST['fecha'] <> "" and $_POST['nombre_nino'] <> "" and $_POST['sexo'] <> "" and $_POST['dia'] <> "" and $_POST['mes'] <> "" and $_POST['year'] <> "" and $_POST['nacido'] <> "" and $_POST['hora'] <> "" and $_POST['minutos'] <> "" and $_POST['am_pm'] <> "" and $_POST['lugar_nino'] <> "" and $_POST['municipio_nino'] <> "" and $_POST['estado_nino'] <> "" and $_POST['nombre_testigo1'] <> "" and $_POST['cedula_testigo1'] <> "" and $_POST['nombre_testigo2'] <> "" and $_POST['cedula_testigo2'] <> "" and $_POST['nombre_madre'] <> "" and $_POST['cedula_madre'] <> "" and $_POST['edad_madre'] <> "" and $_POST['nacionalidad_madre'] <> "" and $_POST['civil_madre'] <> "" and $_POST['prof_madre'] <> "" and $_POST['domicilio_madre'] <> "" and $_POST['lugar_madre'] <> "" and $_POST['municipio_madre'] <> "" and $_POST['estado_madre'] <> "" and $_POST['nombre_padre'] <> "" and $_POST['cedula_padre'] <> "" and $_POST['edad_padre'] <> "" and $_POST['nacionalidad_padre'] <> "" and $_POST['civil_padre'] <> "" and $_POST['prof_padre'] <> "" and $_POST['domicilio_padre'] <> "" and $_POST['lugar_padre'] <> "" and $_POST['municipio_padre'] <> "" and $_POST['estado_padre'] <> "" and $_POST['rad_presentacion'] <> "" and $_POST['nombre_otro'] <> "" and $_POST['cedula_otro'] <> "" and $_POST['edad_otro'] <> "" and $_POST['nacionalidad_otro'] <> "" and $_POST['civil_otro'] <> "" and $_POST['prof_otro'] <> "" and $_POST['parentesco'] <> "" and $_POST['domicilio_otro'] <> "" and $_POST['lugar_otro'] <> "" and $_POST['municipio_otro'] <> "" and $_POST['estado_otro'] <> "" and $_POST['nota_marginal'] <> "") {
  127.  
  128.  
  129. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora,$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  130. $query = mysql_query($consulta); mysql_close($con); }}?>
  131. <form action="registrar_nacimiento.php" name="formul" method="post">
  132.  
  133. <?php
  134. $fecha_reg = date("d-m-Y");
  135. $anio_reg = date("Y");
  136. ?>

aqui la tabla de la bd

Código SQL:
Ver original
  1. --
  2.  
  3.  
  4. CREATE TABLE IF NOT EXISTS `nacimientos` (
  5.   `ano` INT(11) NOT NULL,
  6.   `numero` INT(11) NOT NULL,
  7.   `fecha` DATE NOT NULL,
  8.   `folio` VARCHAR(20) NOT NULL,
  9.   `autoridad` VARCHAR(60) NOT NULL,
  10.   `cargo_autoridad` VARCHAR(60) NOT NULL,
  11.   `cedula_autoridad` INT(11) NOT NULL,
  12.   `nombre_madre` VARCHAR(60) NOT NULL,
  13.   `edad_madre` INT(11) NOT NULL,
  14.   `nacionalidad_madre` VARCHAR(20) NOT NULL,
  15.   `civil_madre` VARCHAR(15) NOT NULL,
  16.   `cedula_madre` INT(11) NOT NULL,
  17.   `prof_madre` VARCHAR(100) NOT NULL,
  18.   `domicilio_madre` VARCHAR(300) NOT NULL,
  19.   `ciudad_madre` VARCHAR(30) NOT NULL,
  20.   `municipio_madre` VARCHAR(20) NOT NULL,
  21.   `estado_madre` VARCHAR(20) NOT NULL,
  22.   `presenta_madre` INT(11) NOT NULL,
  23.   `nombre_padre` VARCHAR(60) NOT NULL,
  24.   `edad_padre` INT(11) NOT NULL,
  25.   `nacionalidad_padre` VARCHAR(20) NOT NULL,
  26.   `civil_padre` VARCHAR(15) NOT NULL,
  27.   `cedula_padre` INT(11) NOT NULL,
  28.   `prof_padre` VARCHAR(100) NOT NULL,
  29.   `domicilio_padre` VARCHAR(300) NOT NULL,
  30.   `ciudad_padre` VARCHAR(30) NOT NULL,
  31.   `municipio_padre` VARCHAR(20) NOT NULL,
  32.   `estado_padre` VARCHAR(20) NOT NULL,
  33.   `presenta_padre` INT(11) NOT NULL,
  34.   `nombre_nino` VARCHAR(60) NOT NULL,
  35.   `sexo_nino` INT(11) NOT NULL,
  36.   `fecha_nino` DATE NOT NULL,
  37.   `hospital` VARCHAR(100) NOT NULL,
  38.   `hora` INT(11) NOT NULL,
  39.   `minuto` INT(11) NOT NULL,
  40.   `am_pm` INT(11) NOT NULL,
  41.   `ciudad_nino` VARCHAR(30) NOT NULL,
  42.   `municipio_nino` VARCHAR(20) NOT NULL,
  43.   `estado_nino` VARCHAR(20) NOT NULL,
  44.   `legitimo` VARCHAR(2) NOT NULL,
  45.   `cedula_testigo1` INT(11) NOT NULL,
  46.   `nombre_testigo1` VARCHAR(60) NOT NULL,
  47.   `cedula_testigo2` INT(11) NOT NULL,
  48.   `nombre_testigo2` VARCHAR(60) NOT NULL,
  49.   `nombre_otro` VARCHAR(60) NOT NULL,
  50.   `cedula_otro` INT(11) NOT NULL,
  51.   `edad_otro` INT(11) NOT NULL,
  52.   `nacionalidad_otro` VARCHAR(20) NOT NULL,
  53.   `civil_otro` VARCHAR(15) NOT NULL,
  54.   `prof_otro` VARCHAR(100) NOT NULL,
  55.   `parentesco` VARCHAR(30) NOT NULL,
  56.   `domicilio_otro` VARCHAR(200) NOT NULL,
  57.   `ciudad_otro` VARCHAR(30) NOT NULL,
  58.   `municipio_otro` VARCHAR(20) NOT NULL,
  59.   `estado_otro` VARCHAR(20) NOT NULL,
  60.   `op_marginal` VARCHAR(2) NOT NULL,
  61.   `nota_marginal` text NOT NULL,
  62.   `usuario` VARCHAR(20) NOT NULL

de ante mano gracias por su ayuda..
  #2 (permalink)  
Antiguo 21/03/2014, 00:20
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: sos con registro a base de datos no registra

Bueno, ¿y debemos ejecutar el código mentalmente para adivinar el problema?

Vamos, que tienes que depurar tu código, posibles errores, etc.

Sencillamente no es posible ayudar así.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 21/03/2014, 05:30
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

Por lo pronto, esa tabla es un espanto de desnormalización, lo que en la aplicación se traduce en serias dificultades para depurar errores de datos.
Ese esquema no sirve para registraciones de nacimientos.
Por otro lado, como son tantos datos, debuggear donde y en qué punto se producen los fallos puede llevarte mucho tiempo. en cambio, normalizando la tabla y generando diferntes INSERTs para cada bloque de datos, resulta mas simple saber que segmento de todo genera el error.
Como sea, a menos que nos expliques claramente (@paketetrueke dixit), cual es el error que ves.... no vamos a usar tiempo intentando adivinarlo.

¿Cuál es exactamente el problema que tienes, además de un diseño de datos bastante malo?
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #4 (permalink)  
Antiguo 21/03/2014, 06:11
Avatar de evolutionrgm  
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años
Puntos: 5
Respuesta: sos con registro a base de datos no registra

madre de dios nunca habia visto una tabla con tantos datos .. pero ayuda te arroja algun error .. la conexion te la esta tomando .. o pasa dice que registra y no lo hace . rutea el codigo debajo del insert tira un linea 138

Código PHP:
Ver original
  1. echo $query;

partamos por eso te sale algun error .. pero viendo eso me imagino que te debe faltar algun campo a ingresar

suerte
  #5 (permalink)  
Antiguo 21/03/2014, 06:23
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

Mirando con cuidado sólo la query, pero ordenandolá, vemos:
Código SQL:
Ver original
  1. INSERT INTO nacimientos VALUES(
  2. '$post_ano',
  3. '$post_numero',
  4. '$post_fecha_t',
  5. '$post_folio',
  6. '$post_aut',
  7. '$post_cargo',
  8. '$post_cedula_aut',
  9. '$post_nombre_madre',
  10. $post_edad_madre,
  11. '$post_nacionalidad_madre',
  12. '$post_civil_madre',
  13. '$post_cedula_madre',
  14. '$post_prof_madre',
  15. '$post_domicilio_madre',
  16. '$post_lugar_madre',
  17. '$post_municipio_madre',
  18. '$post_estado_madre',
  19. '$post_pre_madre',
  20. '$post_nombre_padre',
  21. '$post_edad_padre',
  22. '$post_nacionalidad_padre',
  23. '$post_civil_padre',
  24. '$post_cedula_padre',
  25. '$post_prof_padre',
  26. '$post_domicilio_padre',
  27. '$post_lugar_padre',
  28. '$post_municipio_padre',
  29. '$post_estado_padre',
  30. '$post_pre_padre',
  31. '$post_nombre_nino',
  32. '$post_sexo_t',
  33. '$post_fecha_nac',
  34. '$post_nacido',
  35. '$post_hora,$post_minutos',
  36. '$post_am_pm_t',
  37. '$post_lugar_nino',
  38. '$post_municipio_nino',
  39. '$post_estado_nino',
  40. '$post_legitimo',
  41. '$post_cedula_testigo1,
  42. '$post_nombre_testigo1',
  43. '$post_cedula_testigo2',
  44. '$post_nombre_testigo2',
  45. '$post_nombre_otro',
  46. '$post_cedula_otro',
  47. '$post_edad_otro',
  48. '$post_nacionalidad_otro',
  49. '$post_civil_otro',
  50. '$post_prof_otro',
  51. '$post_parentesco',
  52. '$post_domicilio_otro',
  53. '$post_lugar_otro',
  54. '$post_municipio_otro',
  55. '$post_estado_otro',
  56. '$post_op_marginal_t',
  57. '$post_nota_marginal',
  58. '$post_usuario');
Aquí hay al menos un error:
Código SQL:
Ver original
  1. '$post_hora,$post_minutos',
En ese punto hay apostrofos mal cerrados.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #6 (permalink)  
Antiguo 21/03/2014, 07:30
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

Hola bien si están en lo cierto no aclare con precisión el problema. como tal no me manda ningún error solo que los datos no se almacenan. trate de modificar algunos datos y en fecto almacena la información pero no como debería.

tratare de colgar el código en varias entradas a ver si pueden ayudarme.

parte I

Código PHP:
Ver original
  1. <body>
  2. <?php
  3. include ("config.php");
  4. $con=mysql_connect($host,$user,$pass);
  5. if (!$con) {
  6. die('Problemas con el servidor: ' . mysql_error());
  7. }
  8. $db_selected = mysql_select_db($db,$con);
  9. if (!$db_selected) {
  10. die ('Error al conectar a la BD. : ' . mysql_error());
  11. }
  12. if (isset($_POST['guardar'])) {
  13.  
  14. $post_ano = $_POST['ano'];
  15. $post_numero = $_POST['numero'];
  16. $post_folio = $_POST['folio'];
  17. $post_fecha = $_POST['fecha'];
  18.  
  19. $post_aut = $_POST['nombre_aut'];
  20. $post_cargo = $_POST['cargo'];
  21. $post_cedula_aut = $_POST['cedula_aut'];
  22.  
  23. $post_nombre_nino = strtoupper($_POST['nombre_nino']);
  24. $post_sexo = $_POST['sexo'];
  25. $post_dia = $_POST['dia'];
  26. $post_mes = $_POST['mes'];
  27. $post_year = $_POST['year'];
  28. $post_nacido = strtoupper($_POST['nacido']);
  29. $post_hora = $_POST['hora'];
  30. $post_minutos = $_POST['minutos'];
  31. $post_am_pm = $_POST['am_pm'];
  32. $post_lugar_nino = strtoupper($_POST['lugar_nino']);
  33. $post_municipio_nino = strtoupper($_POST['municipio_nino']);
  34. $post_estado_nino = strtoupper($_POST['estado_nino']);
  35. $post_legitimo = strtoupper($_POST['legitimo']);
  36.  
  37. $post_nombre_testigo1 = strtoupper($_POST['nombre_testigo1']);
  38. $post_cedula_testigo1 = $_POST['cedula_testigo1'];
  39. $post_nombre_testigo2 = strtoupper($_POST['nombre_testigo2']);
  40. $post_cedula_testigo2 = $_POST['cedula_testigo2'];
  41.  
  42. $post_nombre_madre = strtoupper($_POST['nombre_madre']);
  43. $post_cedula_madre = $_POST['cedula_madre'];
  44. $post_edad_madre = $_POST['edad_madre'];
  45. $post_nacionalidad_madre = $_POST['nacionalidad_madre'];
  46. $post_civil_madre = $_POST['civil_madre'];
  47. $post_prof_madre = strtoupper($_POST['prof_madre']);
  48. $post_domicilio_madre = strtoupper($_POST['domicilio_madre']);
  49. $post_lugar_madre = strtoupper($_POST['lugar_madre']);
  50. $post_municipio_madre = strtoupper($_POST['municipio_madre']);
  51. $post_estado_madre = strtoupper($_POST['estado_madre']);
  52.  
  53. $post_nombre_padre = strtoupper($_POST['nombre_padre']);
  54. $post_cedula_padre = $_POST['cedula_padre'];
  55. $post_edad_padre = $_POST['edad_padre'];
  56. $post_nacionalidad_padre = $_POST['nacionalidad_padre'];
  57. $post_civil_padre = $_POST['civil_padre'];
  58. $post_prof_padre = strtoupper($_POST['prof_padre']);
  59. $post_domicilio_padre = strtoupper($_POST['domicilio_padre']);
  60. $post_lugar_padre = strtoupper($_POST['lugar_padre']);
  61. $post_municipio_padre = strtoupper($_POST['municipio_padre']);
  62. $post_estado_padre = strtoupper($_POST['estado_padre']);
  63.  
  64. $post_nombre_otro = strtoupper($_POST['nombre_otro']);
  65. $post_cedula_otro = $_POST['cedula_otro'];
  66. $post_edad_otro = $_POST['edad_otro'];
  67. $post_nacionalidad_otro = $_POST['nacionalidad_otro'];
  68. $post_civil_otro = $_POST['civil_otro'];
  69. $post_prof_otro = strtoupper($_POST['prof_otro']);
  70. $post_parentesco = strtoupper($_POST['parentesco']);
  71. $post_domicilio_otro = strtoupper($_POST['domicilio_otro']);
  72. $post_lugar_otro = strtoupper($_POST['lugar_otro']);
  73. $post_municipio_otro = strtoupper($_POST['municipio_otro']);
  74. $post_estado_otro = strtoupper($_POST['estado_otro']);
  75.  
  76. $post_usuario = $_SESSION['username'];
  77.  
  78.  
  79. $post_presentacion = $_POST['rad_presentacion'];
  80. if ($post_presentacion == 'rad_padre') {
  81.  $post_pre_padre = 1;
  82.  $post_pre_madre = 0;
  83.  $post_pre_otro = 0;
  84. }
  85.  
  86. if ($post_presentacion == 'rad_madre') {
  87.  $post_pre_padre = 0;
  88.  $post_pre_madre = 1;
  89.  $post_pre_otro = 0;
  90. }
  91.  
  92. if ($post_presentacion == 'rad_otro') {
  93.  $post_pre_padre = 0;
  94.  $post_pre_madre = 0;
  95.  $post_pre_otro = 1;
  96. }
  97.  
  98. $post_op_marginal = $_POST['rad_marginal'];
  99. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  100. if ($post_op_marginal == 'nota_si') {
  101.  $post_op_marginal_t = "SI";
  102. }
  103. if ($post_op_marginal == 'nota_no') {
  104.  $post_op_marginal_t = "NO";
  105. }
  106.  
  107. if ($post_am_pm == 'AM'){
  108.    $post_am_pm_t = 1;
  109. }
  110. if ($post_am_pm == 'PM'){
  111.    $post_am_pm_t = 2;
  112. }
  113. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  114. $post_fecha_t = "$aniox-$mesx-$diax";
  115.  
  116. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  117.  
  118. if ($post_sexo=="MASCULINO") {
  119.     $post_sexo_t = 1;
  120.     } else {
  121.     $post_sexo_t = 2;
  122. }
  123.  
  124. if ($_POST['ano'] <> "" and $_POST['numero'] <> "" and $_POST['folio'] <> "" and $_POST['fecha'] <> "" and $_POST['nombre_nino'] <> "" and $_POST['sexo'] <> "" and $_POST['dia'] <> "" and $_POST['mes'] <> "" and $_POST['year'] <> "" and $_POST['nacido'] <> "" and $_POST['hora'] <> "" and $_POST['minutos'] <> "" and $_POST['am_pm'] <> "" and $_POST['lugar_nino'] <> "" and $_POST['municipio_nino'] <> "" and $_POST['estado_nino'] <> "" and $_POST['nombre_testigo1'] <> "" and $_POST['cedula_testigo1'] <> "" and $_POST['nombre_testigo2'] <> "" and $_POST['cedula_testigo2'] <> "" and $_POST['nombre_madre'] <> "" and $_POST['cedula_madre'] <> "" and $_POST['edad_madre'] <> "" and $_POST['nacionalidad_madre'] <> "" and $_POST['civil_madre'] <> "" and $_POST['prof_madre'] <> "" and $_POST['domicilio_madre'] <> "" and $_POST['lugar_madre'] <> "" and $_POST['municipio_madre'] <> "" and $_POST['estado_madre'] <> "" and $_POST['nombre_padre'] <> "" and $_POST['cedula_padre'] <> "" and $_POST['edad_padre'] <> "" and $_POST['nacionalidad_padre'] <> "" and $_POST['civil_padre'] <> "" and $_POST['prof_padre'] <> "" and $_POST['domicilio_padre'] <> "" and $_POST['lugar_padre'] <> "" and $_POST['municipio_padre'] <> "" and $_POST['estado_padre'] <> "" and $_POST['rad_presentacion'] <> "" and $_POST['nombre_otro'] <> "" and $_POST['cedula_otro'] <> "" and $_POST['edad_otro'] <> "" and $_POST['nacionalidad_otro'] <> "" and $_POST['civil_otro'] <> "" and $_POST['prof_otro'] <> "" and $_POST['parentesco'] <> "" and $_POST['domicilio_otro'] <> "" and $_POST['lugar_otro'] <> "" and $_POST['municipio_otro'] <> "" and $_POST['estado_otro'] <> "" and $_POST['nota_marginal'] <> "") {
  125.  
  126.  
  127. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora','$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  128. $query = mysql_query($consulta); mysql_close($con); }}?>
  #7 (permalink)  
Antiguo 21/03/2014, 07:43
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

formulario ...........

Código HTML:
Ver original
  1. <form action="registrar_nacimiento.php" name="formul" method="post">
  2. <?php
  3. $fecha_reg = date("d-m-Y");
  4. $anio_reg = date("Y");
  5. ?>
  6. <br>
  7. <br>
  8. <table width="80%" border="0" align="center" bordercolor="#0066FF" cellspacing="0" cellpadding="0">
  9.    <tr>
  10.     <td width="51%" bgcolor="#0066FF" align="left">
  11.      <br>
  12. <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  13.           <tr>
  14.        <td colspan="2" class="primeralinea">
  15.          <font color="#FFFFFF">AÑO - FOLIO</font></td>
  16.       </tr>
  17.  
  18.  
  19.       <tr>
  20.         <td>
  21.          AÑO <font color="ff0000" size="1"></font>:
  22.         </td>
  23.         <td>
  24.           <input type="text" name="ano" size="15" maxlength="6" value = "<?php echo $anio_reg; ?>" onKeyPress="return ValidarNumero(event);">
  25.             </td>
  26.       </tr>
  27.  
  28.         <td width="30%">
  29.           NUMERO:
  30.         </td>
  31.         <td width="70%">
  32.          <input name="numero" type="text" size="15" onKeyUp="Javascript: asignarfoco();" onKeyPress="return ValidarNumero(event);">
  33.         </td>
  34.       </tr>
  35.       <tr>
  36.         <td width="30%">
  37.           FOLIO:
  38.         </td>
  39.         <td width="70%">
  40.          <input name="folio" type="text" size="15">
  41.         </td>
  42.       </tr>
  43.  
  44.       <tr>
  45.       <tr>
  46.         <td width="30%">
  47.           FECHA:
  48.         </td>
  49.         <td width="70%">
  50.          <input name="fecha" type="text" size="15" value = "<?php echo $fecha_reg; ?>">
  51.         </td>
  52.       </tr>
  53.    
  54. </table>
  55. <br>
  56. <?php include ("config.php");
  57. $con=mysql_connect($host,$user,$pass);
  58. if (!$con) {
  59. die('Problemas con el servidor: ' . mysql_error());
  60. }
  61. $db_selected = mysql_select_db($db,$con);
  62. if (!$db_selected) {
  63. die ('Error al conectar a la BD. : ' . mysql_error());
  64. }
  65. $consulta1 = "Select * from autoridad ";
  66. $resultado1 = mysql_query($consulta1, $con);
  67. $lafila1=mysql_fetch_array($resultado1);?>
  68.        <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  69.       <tr>
  70.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">AUTORIDAD CIVIL</font></td>
  71.       </tr>
  72.       <tr>
  73.         <td width="30%">
  74.           NOMBRE:
  75.         </td>
  76.         <td width="70%">
  77.          <input name="nombre_aut" type="text" size="35" value="<?php echo $lafila1['nombre_autoridad_reg'] ?>">
  78.         </td>
  79.       </tr>
  80.       <tr>
  81.         <td width="30%">
  82.           CARGO:
  83.         </td>
  84.         <td width="70%">
  85.          <input name="cargo" type="text" size="35" value = "<?php echo $lafila1['cargo_autoridad_reg'] ?>">
  86.         </td>
  87.       </tr>
  88.       <tr>
  89.         <td width="30%">
  90.           CEDULA:
  91.         </td>
  92.         <td width="70%">
  93.          <input name="cedula_aut" type="text" size="35" value = "<?php echo $lafila1['cedula_autoridad_reg'] ?>" onKeyPress="return ValidarNumero(event);">
  94.         </td>
  95.       </tr>
  96.  
  97.        </table>
  98.  
  99. <br>
  100. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  101.       <tr>
  102.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">DATOS DEL NIÑO</font></td>
  103.       </tr>
  104.       <tr>
  105.         <td width="30%">
  106.           NOMBRE:
  107.         </td>
  108.         <td width="70%">
  109.          <input name="nombre_nino" type="text" size="35">
  110.         </td>
  111.       </tr>
  112.       <tr>
  113.         <td width="30%">
  114.           SEXO:
  115.         </td>
  116.         <td width="70%">
  117.                 <select name="sexo">
  118.                 <option>  </option>
  119.                 <option>MASCULINO</option>
  120.                 <option>FEMENINO</option>
  121.                 </select>
  122.           </td>
  123.       </tr>
  124.       <tr>
  125. <td width="40%">FECHA DE NACIMIENTO:</td>
  126. <td width="60%">
  127. <?php
  128. $fecha_dia = date ("d");
  129. $fecha_mes = date ("m");
  130. $fecha_year = date ("Y");
  131. $meses_nombres=Array(1=>"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  132. echo "<select name=\"dia\">\n";
  133. for ($contador=1; $contador <=31; $contador++){
  134.   if ($fecha_dia==$contador){
  135.      echo "<option value=\"".$contador."\" selected>".$contador."\n";
  136.    }else{
  137.      echo "<option value=\"".$contador."\">".$contador."\n";
  138.    }
  139. }
  140. echo "</select>\n";
  141. echo "<select name=\"mes\">\n";
  142. for ($contador=1; $contador <=12; $contador++){
  143.   if ($fecha_mes==$contador){
  144.      echo "<option value=\"".$contador."\" selected>".$meses_nombres[$contador]."\n";
  145.    }else{
  146.      echo "<option value=\"".$contador."\">".$meses_nombres[$contador]."\n";
  147.    }
  148. }
  149. echo "</select>\n";
  150. echo "<select name=\"year\">\n";
  151. for ($contador=1900; $contador <=($fecha_year+(date ("Y") - $fecha_year)); $contador++){
  152.   if ($fecha_year==$contador){
  153.      echo "<option value=\"".$contador."\" selected>".$contador."\n";
  154.    }else{
  155.      echo "<option value=\"".$contador."\">".$contador."\n";
  156.    }
  157. }
  158. echo "</select>\n";
  159. ?>
  160. </td></tr>
  161.       <tr>
  162.         <td width="30%">
  163.           NACIDO EN:
  164.         </td>
  165.         <td width="70%">
  166.          <input name="nacido" type="text" size="35">
  167.         </td>
  168.       </tr>
  169.  
  170.       <tr>
  171.         <td width="30%">HORA:</td>
  172.         <td width="70%">            <select name="hora">
  173.                             <option>  </option>
  174.                             <option>01</option>
  175.                             <option>02</option>
  176.                        
  177.                             </select>
  178.  
  179.         &nbsp;&nbsp;
  180.                        <select name="minutos">
  181.                            <option>  </option>
  182.                            <option>00</option>
  183.                            <option>01</option>
  184.                      
  185.                          
  186.  
  187.                             </select>
  188.         &nbsp;&nbsp;
  189.                         <select name="am_pm">
  190.                             <option>  </option>
  191.                 <option>AM</option>
  192.                             <option>PM</option>
  193.                             </select></td>
  194.       </tr>
  195.       <tr>
  196.         <td width="30%">
  197.           LUGAR DE NACIMIENTO:
  198.         </td>
  199.         <td width="70%">
  200.          <input name="lugar_nino" type="text" size="35">
  201.         </td>
  202.       </tr>
  203.       <tr>
  204.         <td width="30%">
  205.           MUNICIPIO:
  206.         </td>
  207.         <td width="70%">
  208.          <input name="municipio_nino" type="text" size="35">
  209.         </td>
  210.       </tr>
  211.       <tr>
  212.         <td width="30%">
  213.           ESTADO:
  214.         </td>
  215.         <td width="70%">
  216.          <input name="estado_nino" type="text" size="35">
  217.         </td>
  218.       </tr>
  #8 (permalink)  
Antiguo 21/03/2014, 07:47
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

formulario Parte II

Código HTML:
Ver original
  1. <tr>
  2.         <td width="30%">
  3.           OPCIÓN LEGITIMO:
  4.         </td>
  5.         <td width="70%">
  6.                 <select name="legitimo">
  7.                 <option>SI</option>
  8.                 <option>NO</option>
  9.                 </select>
  10.           </td>
  11.       </tr>
  12. <br>
  13. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  14.       <tr>
  15.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">DATOS DEL PRIMER TESTIGO</font></td>
  16.       </tr>
  17.       <tr>
  18.         <td width="30%">
  19.           NOMBRE:
  20.         </td>
  21.         <td width="70%">
  22.          <input name="nombre_testigo1" type="text" size="35">
  23.         </td>
  24.       </tr>
  25.       <tr>
  26.         <td width="30%">
  27.           CEDULA:
  28.         </td>
  29.         <td width="70%">
  30.          <input name="cedula_testigo1" type="text" size="15" onKeyPress="return ValidarNumero(event);">
  31.         </td>
  32.       </tr>
  33. <br>
  34. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  35.       <tr>
  36.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">DATOS DEL SEGUNDO TESTIGO</font></td>
  37.       </tr>
  38.       <tr>
  39.         <td width="30%">
  40.           NOMBRE:
  41.         </td>
  42.         <td width="70%">
  43.          <input name="nombre_testigo2" type="text" size="35">
  44.         </td>
  45.       </tr>
  46.       <tr>
  47.         <td width="30%">
  48.           CEDULA:
  49.         </td>
  50.         <td width="70%">
  51.          <input name="cedula_testigo2" type="text" size="15" onKeyPress="return ValidarNumero(event);">
  52.         </td>
  53.       </tr>
  54.  
  55.  
  56. <br>
  57. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  58.       <tr>
  59.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">¿QUIEN PRESENTA?</font></td>
  60.       </tr>
  61.       <tr>
  62.           <td width="70%"><center>
  63.       <input name="rad_presentacion" type="radio" value="rad_padre">EL PADRE
  64.       <input name="rad_presentacion" type="radio" value="rad_madre">LA MADRE
  65.       <input name="rad_presentacion" type="radio" value="rad_otro">OTRO
  66.           </center></td>
  67.       </tr>
  68. <br>
  69. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  70.       <tr>
  71.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">NOTA MARGINAL</font></td>
  72.       </tr>
  73.       <tr>
  74.           <td width="70%"><center>
  75.       <input name="rad_marginal" type="radio" value="nota_si" onClick="javascript:opcion_si()">SI
  76.       <input name="rad_marginal" type="radio" value="nota_no" checked onClick="javascript:opcion_no()">NO
  77.          </center></td>
  78.       </tr>
  79.       <tr>
  80.           <td><center><textarea name="nota_marginal" cols="100" rows="5">SIN NOTA MARGINAL</textarea></center></td>
  81.       </tr>
  82.  
  83. <td width="49%" align="center">
  84. <br>
  85. <table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  86.          
  87.             <tr>
  88.               <td colspan="2" align="center" class="primeralinea">
  89.                <center>
  90.                 <font color="#FFFFFF">DATOS DE LA MADRE</font>
  91.                 </center>
  92.               </td>
  93.             </tr>        
  94.             <tr>
  95.               <td align="left">
  96.                 NOMBRE:
  97.               </td>
  98.               <td align="left">
  99.                 <input type="text" name="nombre_madre" size="45" maxlength="50">
  100.               </td>  
  101.             </tr>
  102.             <tr>               
  103.             <td align="left"> CEDULA:</td>
  104.                <td align="left">
  105.                   <input name="cedula_madre" type="text" size="45" maxlength="50" onKeyPress="return ValidarNumero(event);">
  106.                </td>
  107.             </tr>
  108.             <tr>
  109.               <td colspan="2" align="center">
  110.               </td>
  111.             </tr>
  112.             <tr>               
  113.             <td align="left"> EDAD:</td>
  114.                <td align="left">
  115.                   <input name="edad_madre" type="text" size="45" maxlength="50" onKeyPress="return ValidarNumero(event);">
  116.                </td>
  117.             </tr>
  118.             <tr>
  119.               <td colspan="2" align="center">
  120.               </td>
  121.             </tr>
  122.        <tr>        
  123.                <td align="left"> NACIONALIDAD:</td>
  124.            <td align="left">
  125.                 <select name="nacionalidad_madre">
  126.                 <option>  </option>
  127.                 <option>VENEZOLANA</option>
  128.                 <option>EXTRANJERA</option>
  129.                 </select>
  130.            </td>
  131.        </tr>
  132.        <tr>
  133.          <td colspan="2" align="center">
  134.          </td>
  135.        </tr>
  136.        <tr>        
  137.                <td align="left"> ESTADO CIVIL:</td>
  138.            <td align="left">
  139.                 <select name="civil_madre">
  140.                 <option>  </option>
  141.                 <option>SOLTERA</option>
  142.                 <option>CASADA</option>
  143.                 <option>DIVORCIADA</option>
  144.                 <option>VIUDA</option>
  145.                 </select>
  146.            </td>
  147.        </tr>
  148.        <tr>
  149.          <td colspan="2" align="center">
  150.          </td>
  151.        </tr>
  152.        <tr>            
  153.                <td align="left"> PROFESION U OFICIO:</td>
  154.            <td align="left">
  155.          <input name="prof_madre" type="text" size="45" maxlength="50">
  156.            </td>
  157.        </tr>
  158.        <tr>
  159.          <td colspan="2" align="center">
  160.          </td>
  161.        </tr>
  162.        <tr>        
  163.                <td align="left"> DOMICILIO:</td>
  164.            <td align="left">
  165.          <input name="domicilio_madre" type="text" size="45" maxlength="50">
  166.            </td>
  167.        </tr>
  168.        <tr>
  169.          <td colspan="2" align="center">
  170.          </td>
  171.        </tr>
  172.        <tr>        
  173.                <td align="left"> LUGAR DE NACIMIENTO:</td>
  174.            <td align="left">
  175.          <input name="lugar_madre" type="text" size="45" maxlength="50">
  176.            </td>
  177.        </tr>
  178.        <tr>
  179.          <td colspan="2" align="center">
  180.          </td>
  181.        </tr>
  182.    <tr>        
  183.                <td align="left"> MUNICIPIO:</td>
  184.            <td align="left">
  185.          <input name="municipio_madre" type="text" size="45" maxlength="50">
  186.            </td>
  #9 (permalink)  
Antiguo 21/03/2014, 07:48
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

formulario parte III

Código HTML:
Ver original
  1. </tr>
  2.        <tr>
  3.          <td colspan="2" align="center">
  4.          </td>
  5.        </tr>
  6.  
  7.        <tr>        
  8.                <td align="left"> ESTADO:</td>
  9.            <td align="left">
  10.          <input name="estado_madre" type="text" size="45" maxlength="50">
  11.            </td>
  12.        </tr>
  13.        <tr>
  14.          <td colspan="2" align="center">
  15.          </td>
  16.        </tr>
  17.  
  18.          </table>
  19. <br>
  20. <table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF">         
  21.             <tr>
  22.               <td colspan="2" align="center" class="primeralinea">
  23.                <center>
  24.                 <font color="#FFFFFF">DATOS DEL PADRE</font>
  25.                 </center>
  26.               </td>
  27.             </tr>        
  28.             <tr>
  29.               <td align="left">
  30.                 NOMBRE:
  31.               </td>
  32.               <td align="left">
  33.                 <input type="text" name="nombre_padre" size="45" maxlength="50">
  34.               </td>  
  35.             </tr>
  36.             <tr>               
  37.             <td align="left"> CEDULA:</td>
  38.                <td align="left">
  39.                   <input name="cedula_padre" type="text" size="45" maxlength="50" onKeyPress="return ValidarNumero(event);">
  40.                </td>
  41.             </tr>
  42.             <tr>
  43.               <td colspan="2" align="center">
  44.               </td>
  45.             </tr>
  46.             <tr>               
  47.             <td align="left"> EDAD:</td>
  48.                <td align="left">
  49.                   <input name="edad_padre" type="text" size="45" maxlength="50" onKeyPress="return ValidarNumero(event);">
  50.                </td>
  51.             </tr>
  52.             <tr>
  53.               <td colspan="2" align="center">
  54.               </td>
  55.             </tr>
  56.        <tr>            
  57.                <td align="left"> NACIONALIDAD:</td>
  58.            <td align="left">
  59.                 <select name="nacionalidad_padre">
  60.                 <option>  </option>
  61.              
  62.                 <option>EXTRANJERO</option>
  63.                 </select>
  64.            </td>
  65.        </tr>
  66.        <tr>
  67.          <td colspan="2" align="center">
  68.          </td>
  69.        </tr>
  70.        <tr>        
  71.                <td align="left"> ESTADO CIVIL:</td>
  72.            <td align="left">
  73.                 <select name="civil_padre">
  74.                 <option>  </option>
  75.                 <option>SOLTERO</option>
  76.            
  77.                 </select>
  78.            </td>
  79.        </tr>
  80.        <tr>
  81.          <td colspan="2" align="center">
  82.          </td>
  83.        </tr>
  84.        <tr>            
  85.                <td align="left"> PROFESION U OFICIO:</td>
  86.            <td align="left">
  87.          <input name="prof_padre" type="text" size="45" maxlength="50">
  88.            </td>
  89.        </tr>
  90.        <tr>
  91.          <td colspan="2" align="center">
  92.          </td>
  93.        </tr>
  94.        <tr>            
  95.                <td align="left"> DOMICILIO:</td>
  96.            <td align="left">
  97.          <input name="domicilio_padre" type="text" size="45" maxlength="50">
  98.            </td>
  99.        </tr>
  100.        <tr>
  101.          <td colspan="2" align="center">
  102.          </td>
  103.        </tr>
  104.        <tr>        
  105.                <td align="left"> LUGAR DE NACIMIENTO:</td>
  106.            <td align="left">
  107.          <input name="lugar_padre" type="text" size="45" maxlength="50">
  108.            </td>
  109.        </tr>
  110.        <tr>
  111.          <td colspan="2" align="center">
  112.          </td>
  113.        </tr>
  114.        <tr>        
  115.                <td align="left"> MUNICIPIO:</td>
  116.            <td align="left">
  117.          <input name="municipio_padre" type="text" size="45" maxlength="50">
  118.            </td>
  119.        </tr>
  120.        <tr>
  121.          <td colspan="2" align="center">
  122.          </td>
  123.        </tr>
  124.  
  125.        <tr>
  126.                
  127.                <td align="left"> ESTADO:</td>
  128.            <td align="left">
  129.          <input name="estado_padre" type="text" size="45" maxlength="50">
  130.            </td>
  131.        </tr>
  132.        <tr>
  133.          <td colspan="2" align="center">
  134.          </td>
  135.        </tr>
  136.  
  137.          </table>
  138.  
  139. <br>
  140. <table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  141.          
  142.             <tr>
  143.               <td colspan="2" align="center" class="primeralinea">
  144.                <center>
  145.                 <font color="#FFFFFF">DATOS DEL PRESENTANTE (CUANDO NO SON LOS PADRES)</font>
  146.                 </center>
  147.               </td>
  148.             </tr>        
  149.             <tr>
  150.               <td align="left">
  151.                 NOMBRE:
  152.               </td>
  153.               <td align="left">
  154.                 <input type="text" name="nombre_otro" size="45" maxlength="50" value ="">
  155.               </td>  
  156.             </tr>
  157.             <tr>
  158.                
  159.             <td align="left"> CEDULA:</td>
  160.                <td align="left">
  161.                   <input name="cedula_otro" type="text" size="45" maxlength="50" value ="" onKeyPress="return ValidarNumero(event);">
  162.                </td>
  163.             </tr>
  164.             <tr>
  165.               <td colspan="2" align="center">
  166.               </td>
  167.             </tr>
  168.             <tr>
  169.                
  170.             <td align="left"> EDAD:</td>
  171.                <td align="left">
  172.                   <input name="edad_otro" type="text" size="45" maxlength="50" value ="" onKeyPress="return ValidarNumero(event);">
  173.                </td>
  174.             </tr>
  175.             <tr>
  176.               <td colspan="2" align="center">
  177.               </td>
  178.             </tr>
  179.        <tr>            
  180.                <td align="left"> NACIONALIDAD:</td>
  181.            <td align="left">
  182.                 <select name="nacionalidad_otro">
  183.                 <option>  </option>
  184.                
  185.                 <option>EXTRANJERO(A)</option>
  186.                 </select>
  187.            </td>
  188.        </tr>
  189.        <tr>
  190.          <td colspan="2" align="center">
  191.          </td>
  192.        </tr>
  193.        <tr>            
  194.                <td align="left"> ESTADO CIVIL:</td>
  195.            <td align="left">
  196.                 <select name="civil_otro">
  197.                 <option>SOLTERO(A)</option>
  198.              
  199.                </select>
  200.            </td>
  201.        </tr>
  202.        <tr>
  203.          <td colspan="2" align="center">
  204.          </td>
  205.        </tr>
  206.        <tr>        
  207.                <td align="left"> PARENTESCO:</td>
  208.            <td align="left">
  209.          <input name="parentesco" type="text" size="45" maxlength="50" value ="">
  210.            </td>
  211.        </tr>
  212.        <tr>
  213.          <td colspan="2" align="center">
  214.          </td>
  215.        </tr>
  216.        <tr>
  217.        <tr>            
  218.                <td align="left"> PROFESION U OFICIO:</td>
  219.            <td align="left">
  220.          <input name="prof_otro" type="text" size="45" maxlength="50" value ="">
  221.            </td>
  222.        </tr>
  223.        <tr>
  224.          <td colspan="2" align="center">
  225.          </td>
  226.        </tr>
  227.        <tr>            
  228.               <td align="left"> DOMICILIO:</td>
  229.            <td align="left">
  230.          <input name="domicilio_otro" type="text" size="45" maxlength="50" value ="">
  231.            </td>
  232.        </tr>
  233.        <tr>
  234.          <td colspan="2" align="center">
  235.          </td>
  236.        </tr>
  237.        <tr>            
  238.                <td align="left"> LUGAR DE NACIMIENTO:</td>
  239.            <td align="left">
  240.          <input name="lugar_otro" type="text" size="45" maxlength="50" value ="">
  241.            </td>
  242.        </tr>
  243.        <tr>
  244.          <td colspan="2" align="center">
  245.          </td>
  246.        </tr>
  247.        <tr>            
  248.                <td align="left"> MUNICIPIO:</td>
  249.            <td align="left">
  250.          <input name="municipio_otro" type="text" size="45" maxlength="50" value ="">
  251.            </td>
  252.        </tr>
  253.        <tr>
  254.          <td colspan="2" align="center">
  255.          </td>
  256.        </tr>
  257.        <tr>        
  258.    <td align="left"> ESTADO:</td>
  259.            <td align="left">
  260.          <input name="estado_otro" type="text" size="45" maxlength="50" value ="">
  261.            </td>
  262.        </tr>
  263.        <tr>
  264.          <td colspan="2" align="center">
  265.          </td>
  266.        </tr>
  267. <br>
  268. <tr align="center">
  269.      <td colspan="2" bgcolor="#0066FF">
  270.      <center>
  271.           <br>
  272.            <input name="guardar" type="submit" value="Guardar Datos">
  273.       </center>
  274.      </td>
  275. </tr>
  276. </form>
  #10 (permalink)  
Antiguo 21/03/2014, 07:56
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

Cita:
Iniciado por evolutionrgm Ver Mensaje
madre de dios nunca habia visto una tabla con tantos datos .. pero ayuda te arroja algun error .. la conexion te la esta tomando .. o pasa dice que registra y no lo hace . rutea el codigo debajo del insert tira un linea 138

Código PHP:
Ver original
  1. echo $query;

partamos por eso te sale algun error .. pero viendo eso me imagino que te debe faltar algun campo a ingresar

suerte
Te comento veras, no me manda ningún error pasa todo bien pero no me almacena los datos. hice esto elimine el post de $post_sexo = $_POST['sexo']; y lo deje $sexo = $_POST['sexo']; en efecto me guarda la información pero erronea y la parte donde tengo el if no funciona como deberia si elimino el post en todas las variables.

Código PHP:
Ver original
  1. $post_presentacion = $_POST['rad_presentacion'];
  2. if ($post_presentacion == 'rad_padre') {
  3.  $post_pre_padre = 1;
  4.  $post_pre_madre = 0;
  5.  $post_pre_otro = 0;
  6. }
  7.  
  8. if ($post_presentacion == 'rad_madre') {
  9.  $post_pre_padre = 0;
  10.  $post_pre_madre = 1;
  11.  $post_pre_otro = 0;
  12. }
  13.  
  14. if ($post_presentacion == 'rad_otro') {
  15.  $post_pre_padre = 0;
  16.  $post_pre_madre = 0;
  17.  $post_pre_otro = 1;
  18. }
  19.  
  20. $post_op_marginal = $_POST['rad_marginal'];
  21. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  22. if ($post_op_marginal == 'nota_si') {
  23.  $post_op_marginal_t = "SI";
  24. }
  25. if ($post_op_marginal == 'nota_no') {
  26.  $post_op_marginal_t = "NO";
  27. }
  28.  
  29. if ($post_am_pm == 'AM'){
  30.    $post_am_pm_t = 1;
  31. }
  32. if ($post_am_pm == 'PM'){
  33.    $post_am_pm_t = 2;
  34. }
  35. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  36. $post_fecha_t = "$aniox-$mesx-$diax";
  37.  
  38. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  39.  
  40. if ($post_sexo=="MASCULINO") {
  41.     $post_sexo_t = 1;
  42.     } else {
  43.     $post_sexo_t = 2;
  44. }

gracias por tu ayuda.
  #11 (permalink)  
Antiguo 21/03/2014, 08:03
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

En realidad, más que poner todo ese codigo de formulario (que no afecta el problema), sería mejor que probaras recuperando la query que se crea:
Código PHP:
Ver original
  1. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora,$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  2. echo $consulta;
o bien:
Código PHP:
Ver original
  1. var_dump($consulta);
de esa forma puedes asegurarte qué es lo que queda armado.

Lo que sí veo es que ni siquiera te estás molestando en verificar si la query falló. En tu scrpipt no estás validando si ocurre un fallo, sino que asumes que funcionó.

AL menos haz esto:
Código PHP:
Ver original
  1. $query = mysql_query($consulta) or die("Error: ". mysql_error());
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #12 (permalink)  
Antiguo 21/03/2014, 10:57
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

Cita:
Iniciado por gnzsoloyo Ver Mensaje
En realidad, más que poner todo ese codigo de formulario (que no afecta el problema), sería mejor que probaras recuperando la query que se crea:
Código PHP:
Ver original
  1. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora,$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  2. echo $consulta;
o bien:
Código PHP:
Ver original
  1. var_dump($consulta);
de esa forma puedes asegurarte qué es lo que queda armado.

Lo que sí veo es que ni siquiera te estás molestando en verificar si la query falló. En tu scrpipt no estás validando si ocurre un fallo, sino que asumes que funcionó.

AL menos haz esto:
Código PHP:
Ver original
  1. $query = mysql_query($consulta) or die("Error: ". mysql_error());
Gracias gnzsoloyo por tomar un poco de tiempo en ayudarme.

tal cual habia omitido validar y/o verificar si el query tenia algun fallo.

tengo esto igual no almacena. Intente cambiando esto $post_cargo = $_POST['cargo']; elimine el post deje: $cargo = $_POST['cargo']; por supuesto que el query tambien lo modifique y coloque ('$cargo,`,$etc','$etc') de esa forma si me realiza el registro pero, como nunca falta un pero, tendría que eliminar el post de todas mis variables y eso me afectaría mi condición y no guarda esos campos de forma correcta.

esta es la condicion
Código PHP:
Ver original
  1. $post_presentacion = $_POST['rad_presentacion'];
  2. if ($post_presentacion == 'rad_padre') {
  3.  $post_pre_padre = 1;
  4.  $post_pre_madre = 0;
  5.  $post_pre_otro = 0;
  6. }
  7.  
  8. if ($post_presentacion == 'rad_madre') {
  9.  $post_pre_padre = 0;
  10.  $post_pre_madre = 1;
  11.  $post_pre_otro = 0;
  12. }
  13.  
  14. if ($post_presentacion == 'rad_otro') {
  15.  $post_pre_padre = 0;
  16.  $post_pre_madre = 0;
  17.  $post_pre_otro = 1;
  18. }
  19.  
  20. $post_op_marginal = $_POST['rad_marginal'];
  21. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  22. if ($post_op_marginal == 'nota_si') {
  23.  $post_op_marginal_t = "SI";
  24. }
  25. if ($post_op_marginal == 'nota_no') {
  26.  $post_op_marginal_t = "NO";
  27. }
  28.  
  29. if ($post_am_pm == 'AM'){
  30.    $post_am_pm_t = 1;
  31. }
  32. if ($post_am_pm == 'PM'){
  33.    $post_am_pm_t = 2;
  34. }
  35. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  36. $post_fecha_t = "$aniox-$mesx-$diax";
  37.  
  38. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  39.  
  40. if ($post_sexo=="MASCULINO") {
  41.     $post_sexo_t = 1;
  42.     } else {
  43.     $post_sexo_t = 2;
  44. }

este es el query ya con el or die("Error: ". mysql_error());

Código PHP:
Ver original
  1. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora','$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  2. $query = mysql_query($consulta) or die("Error: ". mysql_error());
  3. }}?>

Gracias por tu tiempo y ayuda.
  #13 (permalink)  
Antiguo 21/03/2014, 12:09
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

Cita:
tengo esto igual no almacena. Intente cambiando esto $post_cargo = $_POST['cargo']; elimine el post deje: $cargo = $_POST['cargo']; por supuesto que el query tambien lo modifique y coloque ('$cargo,`,$etc','$etc') de esa forma si me realiza el registro
LA verdad, analicé el script que nos posteaste en el Netbeans, y no veo cómo peude ser que el prefijo "post_" pueda estar afectando el comportamiento de la query.
¿Llegaste a hacer un var_dump para capturar cómo quedaba armada?
¿Podrías postear eso?
A mi me sigue intrigando.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #14 (permalink)  
Antiguo 21/03/2014, 19:19
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

este es el resultado del var_dump me dice que tengo un error estoy revisando y de verdad no veo el error según la documentación la consulta no concuerda el numero de campo con los valores.

Código SQL:
Ver original
  1. string 'insert into nacimientos values('2014','4444','2014-03-22','jj','prueba','gerente','xxxx','III','14','EXTRANJERA','SOLTERA','000','MMMM','MMM','MMM','MMM','MMM','1','KKK','88','EXTRANJERO','SOLTERO','8888','VVV','VV','VVV','VV','VVV','0','JJJJ','1','2014-3-22','JJJJJJ','02','00','1','JJJ','JJJ','JJJ','SI','666','JJJJ','444','HHH','VVVVVVVV','333','21','VENEZOLANO(A)','CASADO(A)','AAA','AAA','AAA','AAA','AAA','AAA','NO','SIN NOTA MARGINAL','administrador');' (LENGTH=463)
  2. Error: COLUMN COUNT doesn't match value count at row 1

te muestro nuevamente los valores que recibo el query y la bd

Código PHP:
Ver original
  1. <?php
  2. include ("config.php");
  3. $con=mysql_connect($host,$user,$pass);
  4. if (!$con) {
  5. die('Problemas con el servidor: ' . mysql_error());
  6. }
  7. $db_selected = mysql_select_db($db,$con);
  8. if (!$db_selected) {
  9. die ('Error al conectar a la BD. : ' . mysql_error());
  10. }
  11. if (isset($_POST['guardar'])) {
  12.  
  13. $post_ano = $_POST['ano'];
  14. $post_numero = $_POST['numero'];
  15. $post_folio = $_POST['folio'];
  16. $post_fecha = $_POST['fecha'];
  17.  
  18. $post_aut = $_POST['nombre_aut'];
  19. $post_cargo = $_POST['cargo'];
  20. $post_cedula_aut = $_POST['cedula_aut'];
  21.  
  22. $post_nombre_nino = strtoupper($_POST['nombre_nino']);
  23. $post_sexo = $_POST['sexo'];
  24. $post_dia = $_POST['dia'];
  25. $post_mes = $_POST['mes'];
  26. $post_year = $_POST['year'];
  27. $post_nacido = strtoupper($_POST['nacido']);
  28. $post_hora = $_POST['hora'];
  29. $post_minutos = $_POST['minutos'];
  30. $post_am_pm = $_POST['am_pm'];
  31. $post_lugar_nino = strtoupper($_POST['lugar_nino']);
  32. $post_municipio_nino = strtoupper($_POST['municipio_nino']);
  33. $post_estado_nino = strtoupper($_POST['estado_nino']);
  34. $post_legitimo = strtoupper($_POST['legitimo']);
  35.  
  36. $post_nombre_testigo1 = strtoupper($_POST['nombre_testigo1']);
  37. $post_cedula_testigo1 = $_POST['cedula_testigo1'];
  38. $post_nombre_testigo2 = strtoupper($_POST['nombre_testigo2']);
  39. $post_cedula_testigo2 = $_POST['cedula_testigo2'];
  40.  
  41. $post_nombre_madre = strtoupper($_POST['nombre_madre']);
  42. $post_cedula_madre = $_POST['cedula_madre'];
  43. $post_edad_madre = $_POST['edad_madre'];
  44. $post_nacionalidad_madre = $_POST['nacionalidad_madre'];
  45. $post_civil_madre = $_POST['civil_madre'];
  46. $post_prof_madre = strtoupper($_POST['prof_madre']);
  47. $post_domicilio_madre = strtoupper($_POST['domicilio_madre']);
  48. $post_lugar_madre = strtoupper($_POST['lugar_madre']);
  49. $post_municipio_madre = strtoupper($_POST['municipio_madre']);
  50. $post_estado_madre = strtoupper($_POST['estado_madre']);
  51.  
  52. $post_nombre_padre = strtoupper($_POST['nombre_padre']);
  53. $post_cedula_padre = $_POST['cedula_padre'];
  54. $post_edad_padre = $_POST['edad_padre'];
  55. $post_nacionalidad_padre = $_POST['nacionalidad_padre'];
  56. $post_civil_padre = $_POST['civil_padre'];
  57. $post_prof_padre = strtoupper($_POST['prof_padre']);
  58. $post_domicilio_padre = strtoupper($_POST['domicilio_padre']);
  59. $post_lugar_padre = strtoupper($_POST['lugar_padre']);
  60. $post_municipio_padre = strtoupper($_POST['municipio_padre']);
  61. $post_estado_padre = strtoupper($_POST['estado_padre']);
  62.  
  63. $post_nombre_otro = strtoupper($_POST['nombre_otro']);
  64. $post_cedula_otro = $_POST['cedula_otro'];
  65. $post_edad_otro = $_POST['edad_otro'];
  66. $post_nacionalidad_otro = $_POST['nacionalidad_otro'];
  67. $post_civil_otro = $_POST['civil_otro'];
  68. $post_prof_otro = strtoupper($_POST['prof_otro']);
  69. $post_parentesco = strtoupper($_POST['parentesco']);
  70. $post_domicilio_otro = strtoupper($_POST['domicilio_otro']);
  71. $post_lugar_otro = strtoupper($_POST['lugar_otro']);
  72. $post_municipio_otro = strtoupper($_POST['municipio_otro']);
  73. $post_estado_otro = strtoupper($_POST['estado_otro']);
  74.  
  75. $post_usuario = $_SESSION['username'];
  76.  
  77.  
  78. $post_presentacion = $_POST['rad_presentacion'];
  79. if ($post_presentacion == 'rad_padre') {
  80.  $post_pre_padre = 1;
  81.  $post_pre_madre = 0;
  82.  $post_pre_otro = 0;
  83. }
  84.  
  85. if ($post_presentacion == 'rad_madre') {
  86.  $post_pre_padre = 0;
  87.  $post_pre_madre = 1;
  88.  $post_pre_otro = 0;
  89. }
  90.  
  91. if ($post_presentacion == 'rad_otro') {
  92.  $post_pre_padre = 0;
  93.  $post_pre_madre = 0;
  94.  $post_pre_otro = 1;
  95. }
  96.  
  97. $post_op_marginal = $_POST['rad_marginal'];
  98. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  99. if ($post_op_marginal == 'nota_si') {
  100.  $post_op_marginal_t = "SI";
  101. }
  102. if ($post_op_marginal == 'nota_no') {
  103.  $post_op_marginal_t = "NO";
  104. }
  105.  
  106. if ($post_am_pm == 'AM'){
  107.    $post_am_pm_t = 1;
  108. }
  109. if ($post_am_pm == 'PM'){
  110.    $post_am_pm_t = 2;
  111. }
  112. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  113. $post_fecha_t = "$aniox-$mesx-$diax";
  114.  
  115. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  116.  
  117. if ($post_sexo=="MASCULINO") {
  118.     $post_sexo_t = 1;
  119.     } else {
  120.     $post_sexo_t = 2;
  121. }
  122.  
  123. if ($_POST['ano'] <> "" and $_POST['numero'] <> "" and $_POST['folio'] <> "" and $_POST['fecha'] <> "" and $_POST['nombre_nino'] <> "" and $_POST['sexo'] <> "" and $_POST['dia'] <> "" and $_POST['mes'] <> "" and $_POST['year'] <> "" and $_POST['nacido'] <> "" and $_POST['hora'] <> "" and $_POST['minutos'] <> "" and $_POST['am_pm'] <> "" and $_POST['lugar_nino'] <> "" and $_POST['municipio_nino'] <> "" and $_POST['estado_nino'] <> "" and $_POST['nombre_testigo1'] <> "" and $_POST['cedula_testigo1'] <> "" and $_POST['nombre_testigo2'] <> "" and $_POST['cedula_testigo2'] <> "" and $_POST['nombre_madre'] <> "" and $_POST['cedula_madre'] <> "" and $_POST['edad_madre'] <> "" and $_POST['nacionalidad_madre'] <> "" and $_POST['civil_madre'] <> "" and $_POST['prof_madre'] <> "" and $_POST['domicilio_madre'] <> "" and $_POST['lugar_madre'] <> "" and $_POST['municipio_madre'] <> "" and $_POST['estado_madre'] <> "" and $_POST['nombre_padre'] <> "" and $_POST['cedula_padre'] <> "" and $_POST['edad_padre'] <> "" and $_POST['nacionalidad_padre'] <> "" and $_POST['civil_padre'] <> "" and $_POST['prof_padre'] <> "" and $_POST['domicilio_padre'] <> "" and $_POST['lugar_padre'] <> "" and $_POST['municipio_padre'] <> "" and $_POST['estado_padre'] <> "" and $_POST['rad_presentacion'] <> "" and $_POST['nombre_otro'] <> "" and $_POST['cedula_otro'] <> "" and $_POST['edad_otro'] <> "" and $_POST['nacionalidad_otro'] <> "" and $_POST['civil_otro'] <> "" and $_POST['prof_otro'] <> "" and $_POST['parentesco'] <> "" and $_POST['domicilio_otro'] <> "" and $_POST['lugar_otro'] <> "" and $_POST['municipio_otro'] <> "" and $_POST['estado_otro'] <> "" and $_POST['nota_marginal'] <> "") {
  124.  
  125.  
  126. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre','$post_edad_madre','$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora','$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1','$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  127. var_dump ($consulta);
  128. $query = mysql_query($consulta) or die("Error: ". mysql_error());
  129. }}?>

esta en la bd

Código SQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `nacimientos` (
  2.   `ano` INT(11) NOT NULL,
  3.   `numero` INT(11) NOT NULL,
  4.   `fecha` DATE NOT NULL,
  5.   `folio` VARCHAR(20) NOT NULL,
  6.   `autoridad` VARCHAR(60) NOT NULL,
  7.   `cargo_autoridad` VARCHAR(60) NOT NULL,
  8.   `cedula_autoridad` INT(11) NOT NULL,
  9.   `nombre_madre` VARCHAR(60) NOT NULL,
  10.   `edad_madre` INT(11) NOT NULL,
  11.   `nacionalidad_madre` VARCHAR(20) NOT NULL,
  12.   `civil_madre` VARCHAR(15) NOT NULL,
  13.   `cedula_madre` INT(11) NOT NULL,
  14.   `prof_madre` VARCHAR(100) NOT NULL,
  15.   `domicilio_madre` VARCHAR(300) NOT NULL,
  16.   `ciudad_madre` VARCHAR(30) NOT NULL,
  17.   `municipio_madre` VARCHAR(20) NOT NULL,
  18.   `estado_madre` VARCHAR(20) NOT NULL,
  19.   `presenta_madre` INT(11) NOT NULL,
  20.   `nombre_padre` VARCHAR(60) NOT NULL,
  21.   `edad_padre` INT(11) NOT NULL,
  22.   `nacionalidad_padre` VARCHAR(20) NOT NULL,
  23.   `civil_padre` VARCHAR(15) NOT NULL,
  24.   `cedula_padre` INT(11) NOT NULL,
  25.   `prof_padre` VARCHAR(100) NOT NULL,
  26.   `domicilio_padre` VARCHAR(300) NOT NULL,
  27.   `ciudad_padre` VARCHAR(30) NOT NULL,
  28.   `municipio_padre` VARCHAR(20) NOT NULL,
  29.   `estado_padre` VARCHAR(20) NOT NULL,
  30.   `presenta_padre` INT(11) NOT NULL,
  31.   `nombre_nino` VARCHAR(60) NOT NULL,
  32.   `sexo_nino` INT(11) NOT NULL,
  33.   `fecha_nino` DATE NOT NULL,
  34.   `hospital` VARCHAR(100) NOT NULL,
  35.   `hora` INT(11) NOT NULL,
  36.   `minuto` INT(11) NOT NULL,
  37.   `am_pm` INT(11) NOT NULL,
  38.   `ciudad_nino` VARCHAR(30) NOT NULL,
  39.   `municipio_nino` VARCHAR(20) NOT NULL,
  40.   `estado_nino` VARCHAR(20) NOT NULL,
  41.   `legitimo` VARCHAR(2) NOT NULL,
  42.   `cedula_testigo1` INT(11) NOT NULL,
  43.   `nombre_testigo1` VARCHAR(60) NOT NULL,
  44.   `cedula_testigo2` INT(11) NOT NULL,
  45.   `nombre_testigo2` VARCHAR(60) NOT NULL,
  46.   `nombre_otro` VARCHAR(60) NOT NULL,
  47.   `cedula_otro` INT(11) NOT NULL,
  48.   `edad_otro` INT(11) NOT NULL,
  49.   `nacionalidad_otro` VARCHAR(20) NOT NULL,
  50.   `civil_otro` VARCHAR(15) NOT NULL,
  51.   `prof_otro` VARCHAR(100) NOT NULL,
  52.   `parentesco` VARCHAR(30) NOT NULL,
  53.   `domicilio_otro` VARCHAR(200) NOT NULL,
  54.   `ciudad_otro` VARCHAR(30) NOT NULL,
  55.   `municipio_otro` VARCHAR(20) NOT NULL,
  56.   `estado_otro` VARCHAR(20) NOT NULL,
  57.   `op_marginal` VARCHAR(2) NOT NULL,
  58.   `nota_marginal` text NOT NULL,
  59.   `usuario` VARCHAR(20) NOT NULL

Gracias por la ayuda.
  #15 (permalink)  
Antiguo 21/03/2014, 19:39
 
Fecha de Ingreso: agosto-2010
Ubicación: santiago, CHILE
Mensajes: 564
Antigüedad: 13 años, 8 meses
Puntos: 9
Respuesta: sos con registro a base de datos no registra

en la tabla tienes campos enteros y estas ingresando string y es mas de uno

cambia eso y hacele un echo a la variable $consulta

la query que arroje copiala y ejecutala directamente en la base de datos a ver que sucede, y que error te da si los hay.





bye.
  #16 (permalink)  
Antiguo 21/03/2014, 20:03
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

Cita:
Error: COLUMN COUNT doesn't match value count at row 1
Ese es el error...
La cantidad de columnas no coincide con la cantidad de datos. Hay al menos un dato de más o de menos que la cantidad de columnas de la tabla.
Si no insertas la totalidad de los datos, debes indicar el nombre de las columnas una a una.

En principio pareciera que no, porque tienes 58 datos, y la descripcion de la tabla muestra 58 columnas. Pero ese CREATE TABLE está incompleto. No se ve el cierre de la sentencia, por lo que no podemos estar seguros si realmente están todas las columnas, pero sabiendo que MySQL nunca se equivoca en ese sentido, lo más probable es que haya alguna columna más que no estás viendo (sería mucho más sencillo si la tabla estuviese bien diseñada, pero no es el caso).
Lo más simple es verificar. Ejecuta eso y postea el resultado:

Código MySQL:
Ver original
  1. SHOW CREATE TABLE nacimientos;
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #17 (permalink)  
Antiguo 21/03/2014, 21:16
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

realice algunos cambios y logre que me registrara la información pero esta se registra de forma erronea coloca los datos en los campos equivocados. aquí el show create table nacimientos;

Código SQL:
Ver original
  1. CREATE TABLE `nacimientos` (
  2.  `ano` VARCHAR(11) NOT NULL,
  3.  `numero` VARCHAR(11) NOT NULL,
  4.  `fecha` DATE NOT NULL,
  5.  `folio` VARCHAR(20) NOT NULL,
  6.  `nombre_aut` VARCHAR(60) NOT NULL,
  7.  `cargo` VARCHAR(60) NOT NULL,
  8.  `cedula_aut` VARCHAR(11) NOT NULL,
  9.  `nombre_nino` VARCHAR(60) NOT NULL,
  10.  `sexo_nino` VARCHAR(11) NOT NULL,
  11.  `dia` VARCHAR(20) NOT NULL,
  12.  `mes` VARCHAR(15) NOT NULL,
  13.  `year` VARCHAR(11) NOT NULL,
  14.  `nacido` VARCHAR(100) NOT NULL,
  15.  `hora` VARCHAR(300) NOT NULL,
  16.  `minutos` VARCHAR(30) NOT NULL,
  17.  `am_pm` VARCHAR(20) NOT NULL,
  18.  `lugar_nino` VARCHAR(20) NOT NULL,
  19.  `municipio_nino` VARCHAR(11) NOT NULL,
  20.  `estado_nino` VARCHAR(60) NOT NULL,
  21.  `legitimo` VARCHAR(11) NOT NULL,
  22.  `nombre_testigo1` VARCHAR(20) NOT NULL,
  23.  `cedula_testigo1` VARCHAR(15) NOT NULL,
  24.  `nombre_testigo2` VARCHAR(11) NOT NULL,
  25.  `cedula_testigo2` VARCHAR(100) NOT NULL,
  26.  `rad_presentacion` VARCHAR(300) NOT NULL,
  27.  `rad_marginal` VARCHAR(30) NOT NULL,
  28.  `nombre_madre` VARCHAR(20) NOT NULL,
  29.  `cedula_madre` VARCHAR(20) NOT NULL,
  30.  `edad_madre` VARCHAR(11) NOT NULL,
  31.  `nacionalidad_madre` VARCHAR(60) NOT NULL,
  32.  `civil_madre` VARCHAR(11) NOT NULL,
  33.  `prof_madre` VARCHAR(20) NOT NULL,
  34.  `domicilio_madre` VARCHAR(100) NOT NULL,
  35.  `lugar_madre` VARCHAR(11) NOT NULL,
  36.  `municipio_madre` VARCHAR(11) NOT NULL,
  37.  `estado_madre` VARCHAR(11) NOT NULL,
  38.  `nombre_padre` VARCHAR(30) NOT NULL,
  39.  `cedula_padre` VARCHAR(20) NOT NULL,
  40.  `edad_padre` VARCHAR(20) NOT NULL,
  41.  `nacionalidad_padre` VARCHAR(2) NOT NULL,
  42.  `civil_padre` VARCHAR(11) NOT NULL,
  43.  `prof_padre` VARCHAR(60) NOT NULL,
  44.  `domicilio_padre` VARCHAR(11) NOT NULL,
  45.  `lugar_padre` VARCHAR(60) NOT NULL,
  46.  `municipio_padre` VARCHAR(60) NOT NULL,
  47.  `estado_padre` INT(11) NOT NULL,
  48.  `nombre_otro` INT(11) NOT NULL,
  49.  `cedula_otro` VARCHAR(20) NOT NULL,
  50.  `edad_otro` VARCHAR(15) NOT NULL,
  51.  `nacionalidad_otro` VARCHAR(100) NOT NULL,
  52.  `civil_otro` VARCHAR(30) NOT NULL,
  53.  `prof_otro` VARCHAR(200) NOT NULL,
  54.  `parentesco` VARCHAR(30) NOT NULL,
  55.  `domicilio_otro` VARCHAR(20) NOT NULL,
  56.  `lugar_otro` VARCHAR(20) NOT NULL,
  57.  `municipio_otro` VARCHAR(20) NOT NULL,
  58.  `estado_otro` VARCHAR(20) NOT NULL,
  59.  `usuario` VARCHAR(24) NOT NULL
  60. ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  #18 (permalink)  
Antiguo 21/03/2014, 21:27
Avatar de loncho_rojas
Colaborador
 
Fecha de Ingreso: octubre-2008
Ubicación: En el mejor lugar del mundo
Mensajes: 2.704
Antigüedad: 15 años, 6 meses
Puntos: 175
Respuesta: sos con registro a base de datos no registra

pero porque insistes en hacerlo tan desordenado, porque todo de una vez, porque insistes en que tu table debe ser así? de mirar ese MOTHER_OF_LONG_CODE ya me entra un escalosfrio... empiezas a tener 1 problema, y despues se presenta otro, y no se...

Te lo dijeron de entrada, en todo caso si insistes en que sea así de denso, lo que hubieras hecho es que el usuario inserte sus datos de manera racionada, primero los suyos, haces el insert.. luego los de su madre, haces el update, luego el de su padre, haces el update, pero bueno...
__________________
Ayudo con lo que puedo en el foro, y solo en el foro.. NO MENSAJES PRIVADOS.. NO EMAILS NI SKYPE u OTROS.

Antes de hacer un TOPICO piensa si puedes hallarlo en Google o en el Buscador del Foro...
  #19 (permalink)  
Antiguo 21/03/2014, 21:28
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: sos con registro a base de datos no registra

Cita:
oloca los datos en los campos equivocados
MySQL no coloca los datos en los campos equivocados. Éstás poniendo los datos en el orden incorrecto del VALUE.
Cuando no indicas qué campos se insertarán, debes respetar el orden físico de las columnas de la tabla.

Código SQL:
Ver original
  1. CREATE TABLE TABLA1(
  2. a INT,
  3. b VARCHAR,
  4. c DATE);
Correcto:
Código SQL:
Ver original
  1. INSERT INTO tabla1(b, c, a)
  2. VALUES('texto', '2014-03-21', 12);

Código SQL:
Ver original
  1. INSERT INTO tabla1
  2. VALUES(12, 'texto', '2014-03-21');

Incorrecto:
Código SQL:
Ver original
  1. INSERT INTO tabla1
  2. VALUES('texto', '2014-03-21', 12);

MySQL no analiza los datos semánticamente, ni tampoco puede adivinar que los estás mandando mal.
Y si además tratas todas las cosas como cadenas de texto, es altamente probable que no se disparen errores de sintaxis cuando los datos están en la posición incorrecta.
Esto significa que si vas a insertar datos en un campo numérico no lo pongas entre apóstrofos, y si es de fecha, mételo en una función de conversión, para que la funcion dispare un error cuando encuentre algo que no debe estar allí.
Por ejemplo:
Código SQL:
Ver original
  1. INSERT INTO tabla1(b, c, a)
  2. VALUES('texto', DATE('2014-03-21'), 12);
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #20 (permalink)  
Antiguo 21/03/2014, 22:45
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

estas en lo cierto loncho_rojas en lo que acotas. este no es un trabajo como tal es un proyecto educativo bien esta que no es la mejor forma de tener una tabla, luego que solucione lo del registro la modifico claro esta que hay que modificar casi todo, mejor asi por que se aprende mas. cabe acotar que apenas tengo 5 meses estudiando php/mysql en tan pocas entradas gracias a las excelentes explicaciones de gnzsoloyo he aprendido mucho.

gnzsoloyo revisando el query ya me habia percatado de ese error gracias por la explicación, hasta ahora todo marcha bien excepto el mes y el año veras le asigno a la variable $post_fecha_nac los datos del día,mes y año me queda asi.

Código PHP:
Ver original
  1. $post_fecha_nac = "$post_dia-$post_mes-$post_year";
y en el query lo coloco tal cual
Código PHP:
Ver original
  1. $post_fecha_nac
el dia lo pasa bien pero en el mes me coloca uno por defecto y el año me coloca 0 por defecto.
  #21 (permalink)  
Antiguo 21/03/2014, 22:55
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

Realice este cambio elimine la asignación de la variable

Código PHP:
Ver original
  1. $post_fecha_nac = "$post_dia-$post_mes-$post_year";

y la pase de forma directa en mi query y funciona bien.

Código PHP:
Ver original
  1. $post_dia','$post_mes','$post_year','$

Gracias por la ayuda y sobre todo la enseñanza gnzsoloyo. excelente para un aula en la universidad.
  #22 (permalink)  
Antiguo 22/03/2014, 09:52
Avatar de loncho_rojas
Colaborador
 
Fecha de Ingreso: octubre-2008
Ubicación: En el mejor lugar del mundo
Mensajes: 2.704
Antigüedad: 15 años, 6 meses
Puntos: 175
Respuesta: sos con registro a base de datos no registra

La idea aca es siempre aportar aunque sea minimamente... pero para mi nada justifica una mala practica, al menos no a ese nivel. Podrá ser para la escuela, la facu o para un cliente, pero no es lo correcto...

Es como que te digan, "amigo, conduce por tu carril y no de contramano" y tú insistas en eso porque "chocando carros" vas a aprender a conducir mejor. Nadie es genio cuando se inicia, pero al menos hubieras preguntado en otro post ¿cuál sería la manera correcta de plantear este tipo de proyectos?

Un saludo.
__________________
Ayudo con lo que puedo en el foro, y solo en el foro.. NO MENSAJES PRIVADOS.. NO EMAILS NI SKYPE u OTROS.

Antes de hacer un TOPICO piensa si puedes hallarlo en Google o en el Buscador del Foro...
  #23 (permalink)  
Antiguo 23/03/2014, 21:59
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: sos con registro a base de datos no registra

hola loncho_rojas tienes toda la razon..!! ya he puesto en practica la creación de diversos insert uno para la madre uno para el padre. etc. Gracias por el apoyo.

Etiquetas: fecha, formulario, html, mysql, registro, select, sos, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:00.