PHP - Problemas al cargar datos en mi tabla

 
Vista:

Problemas al cargar datos en mi tabla

Publicado por Edwin (2 intervenciones) el 17/10/2017 20:45:02
Buenas tengo un problema con mi código, no cargar los datos en mi mysql, es un códifo heredado y la verdad es que me estoy iniciando en mysql, si alguien me podría ayudar por favor, les paso el código.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
 
  if(empty($error)){
 
	  //creamos nuevo nombre para que tenga nombre unico
	  $nombre_nuevo2 = $_POST['ci'];
 
	  ///////////////////////////////////////////
 
	   // se agrega "archivo_archivos, extension_archivos y la fecha" a la consulta y dos extra %s separados por comas
 
		$insertSQL = sprintf("INSERT INTO postulantes_2017 (prospecto, nombre, apellido_paterno, apellido_materno, ci, ci_departamento, sexo, departamento_nacimiento, lugar_compra, deposito_bancario)
              VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
               GetSQLValueString($_POST['prospecto'], "text"),
               GetSQLValueString($_POST['nombre'], "text"),
               GetSQLValueString($_POST['apellido_paterno'], "text"),
               GetSQLValueString($_POST['apellido_materno'], "text"),
               GetSQLValueString($_POST['ci'], "text"),
               GetSQLValueString($_POST['ci_departamento'], "text"),
               GetSQLValueString($_POST['sexo'], "text"),
               GetSQLValueString($_POST['departamento_nacimiento'], "text"),
               GetSQLValueString($_POST['lugar_compra'], "text"),
               GetSQLValueString($_POST['deposito_bancario'], "text")
		   );
 
  mysql_select_db($database_connect1, $connect1);
  $Result1 = mysql_query($insertSQL, $connect1) or die(mysql_error());
 
  $insertGoTo = "registro_postulantes_bueno.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
 
}
}
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problemas al cargar datos en mi tabla

Publicado por xve (6935 intervenciones) el 18/10/2017 07:53:30
Hola Edwin, donde te conectas a mysql?
Activa visualizar los errores de PHP o revisa el log del Apache o servidor web que estés utilizando, ahí veras los errores que genera.

recuerda que las instrucciones del tipo mysql_... en php7 ya no existen!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problemas al cargar datos en mi tabla

Publicado por Edwin (2 intervenciones) el 18/10/2017 22:04:34
Hola te cuento que rehice la pagina en php con mysql siguiendo un tutorial en video, y pues funciono en mi computadora, pero al subirla a servidor, no me inserta los datos, puse mismos usuarios bases de datos, campos, etc... pero aún no se que puede ser, por ahi lei que puede ser la versión del php y en el servidor es 7.1.10 y de mi xampp es 7.1.8 por sia
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Problemas al cargar datos en mi tabla

Publicado por Mayeson (4 intervenciones) el 18/10/2017 14:51:44
buen día,

El detalle que tienes es que , en este query no estan contemplados todos los valores en INSER INTO, deberias agregarloz.

1
2
3
4
5
6
7
8
9
10
11
12
$insertSQL = sprintf("INSERT INTO postulantes_2017 (prospecto, nombre, apellido_paterno, apellido_materno, ci, ci_departamento, sexo, departamento_nacimiento, lugar_compra, deposito_bancario)
  VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
   GetSQLValueString($_POST['prospecto'], "text"),
   GetSQLValueString($_POST['nombre'], "text"),
   GetSQLValueString($_POST['apellido_paterno'], "text"),
   GetSQLValueString($_POST['apellido_materno'], "text"),
   GetSQLValueString($_POST['ci'], "text"),
   GetSQLValueString($_POST['ci_departamento'], "text"),
   GetSQLValueString($_POST['sexo'], "text"),
   GetSQLValueString($_POST['departamento_nacimiento'], "text"),
   GetSQLValueString($_POST['lugar_compra'], "text"),
   GetSQLValueString($_POST['deposito_bancario'], "text")
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar