Foros del Web » Programando para Internet » PHP »

Problemas al insertar

Estas en el tema de Problemas al insertar en el foro de PHP en Foros del Web. Hola a todos, Estoy haciendo una aplicacion en dreamweaver. El problema que tengo es que al darle al boton de insertar, me guarda todos los ...
  #1 (permalink)  
Antiguo 01/10/2007, 03:32
Avatar de Phoenix23  
Fecha de Ingreso: agosto-2007
Ubicación: 43.286211, -2.171349
Mensajes: 253
Antigüedad: 16 años, 7 meses
Puntos: 1
Problemas al insertar

Hola a todos,

Estoy haciendo una aplicacion en dreamweaver. El problema que tengo es que al darle al boton de insertar, me guarda todos los datos que quiero guardar pero no se me va a ninguna pagina y la pagina se queda en blanco. No soy capaz de encontrar el fallo y no se lo que puede ser. Aqui os dejo un poco de codigo a ver si alguien puede ayudarme.

Código PHP:
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  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"] == "form1")) {

  
$insertSQL sprintf("INSERT INTO datupertsonalak (NAN, IdPertsonala, Izena, Abizena1, Abizena2, JaiotzeData, IdSexua, Herrialdea, Helbidea, PostaKodea, Telefono1, Telefono2, Faxa, Emaila, InskripzioData, IdIkasketak, IdUdalerria) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
  
                       
GetSQLValueString(strtoupper($_POST['NAN']), "text"),
                       
GetSQLValueString($_POST['IdPertsonala'], "int"),
                       
GetSQLValueString(ucfirst($_POST['Izena']), "text"),
                       
GetSQLValueString(ucfirst($_POST['Abizena1']), "text"),
                       
GetSQLValueString(ucfirst($_POST['Abizena2']), "text"),
                       
GetSQLValueString($_POST['JaiotzeData'], "date"),
                       
GetSQLValueString($_POST['IdSexua'], "int"),
                       
GetSQLValueString(ucfirst($_POST['Herrialdea']), "text"),
                       
GetSQLValueString(ucfirst($_POST['Helbidea']), "text"),
                       
GetSQLValueString($_POST['PostaKodea'], "text"),
                       
GetSQLValueString($_POST['Telefono1'], "text"),
                       
GetSQLValueString($_POST['Telefono2'], "text"),
                       
GetSQLValueString($_POST['Faxa'], "text"),
                       
GetSQLValueString($_POST['Emaila'], "text"),
                       
GetSQLValueString($_POST['InskripzioData'], "date"),
                       
GetSQLValueString($_POST['IdIkasketak'], "int"),
                       
GetSQLValueString($_POST['IdUdalerria'], "int"));

  
mysql_select_db($database_Datuak3$Datuak3);
  
$Result1 mysql_query($insertSQL$Datuak3) or die(mysql_error());
  
  
$NAN strtoupper($_POST['NAN']);
  
 if (!empty(
$_POST["Tituloa"])){  
  
$insertSQL sprintf("INSERT INTO gizarprestaarau (IdPrestaArau, Tituloa, AmaieraData, Zentroa, NAN) VALUES (%s, %s, %s, %s, '$NAN')",
                         
                       
GetSQLValueString($_POST['IdPrestaArau'], "int"),
                       
GetSQLValueString(ucfirst($_POST['Tituloa']), "text"),
                       
GetSQLValueString($_POST['AmaieraData'], "date"),
                       
GetSQLValueString(ucfirst($_POST['Zentroa6']), "text"),
                       
GetSQLValueString(strtoupper('$NAN'), "text"));
                       
                       
     
mysql_select_db($database_Datuak3$Datuak3);
     
$Result1 mysql_query($insertSQL$Datuak3) or die(mysql_error());
 }

?>
Esta uina pequña parte del codigo.
Os agradeceria vuestra ayuda porque ya me estoy volviendo medio loco buscando el fallo.

Gracias de antemano y saludos!!!
  #2 (permalink)  
Antiguo 01/10/2007, 05:25
Avatar de Kelpie  
Fecha de Ingreso: febrero-2002
Ubicación: NorthSpain
Mensajes: 609
Antigüedad: 22 años, 2 meses
Puntos: 8
Re: Problemas al insertar

Si el código que no has puesto es parecido al que has puesto, tiene una explicación lo que te pasa.

No produces ninguna salida y no rediriges a ningún sitio, por lo que el cliente recibe una página vacía...

Para producir algo deberís tener algo como

Código PHP:
echo("Esto se va a leer"); 
Para redirigir deberías tener algo como

Código PHP:
header ("Location=nuevapagina.php"); 
__________________
Kelpie
  #3 (permalink)  
Antiguo 01/10/2007, 05:52
Avatar de Phoenix23  
Fecha de Ingreso: agosto-2007
Ubicación: 43.286211, -2.171349
Mensajes: 253
Antigüedad: 16 años, 7 meses
Puntos: 1
Re: Problemas al insertar

Hola Kelpie,

E probado como me as dicho pero no me va y tambien e puesto:

Código PHP:
$insertGoTo "Gizarteratzea2.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo)); 
y tampoco me funciona. Aunque en otras paginas sin poner nada despues de guardar me vuelve a mostrar la misma pagina vacia como actualizada.

No se que puede ser gracias y saludos!!!
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 12:38.