Foros del Web » Programando para Internet » PHP »

Column `name`cannot be null

Estas en el tema de Column `name`cannot be null en el foro de PHP en Foros del Web. Hola, Estoy haciendo un formulario en Dreamweaver que debe insertar un registro en una tabla. En principio solo he puesto dos campos para insertar y ...
  #1 (permalink)  
Antiguo 04/06/2009, 04:29
Avatar de speedkill  
Fecha de Ingreso: mayo-2009
Ubicación: Graz
Mensajes: 30
Antigüedad: 14 años, 11 meses
Puntos: 1
Column `name`cannot be null

Hola,
Estoy haciendo un formulario en Dreamweaver que debe insertar un registro en una tabla.
En principio solo he puesto dos campos para insertar y un boton enviar.
Cuando inserto texto en los dos campos me da el error de que en uno de ellos el valor no puede ser null, como si no le estuviera poniendo texto. y si modifico el campo para que sea null entonces si me agrega el registro.. pero no puedo meter nada en ese campo.

la bd es mysql.

a alguien le paso algo parecido?
  #2 (permalink)  
Antiguo 04/06/2009, 04:43
Avatar de jpinedo
Colaborador
 
Fecha de Ingreso: septiembre-2003
Ubicación: Lima, Perú
Mensajes: 3.120
Antigüedad: 20 años, 7 meses
Puntos: 41
Respuesta: Column `name`cannot be null

Hola:

Generalmente lo que sucede es que no estás recoiendo correctamente el valor de la variable. Sería mejor que postees el código que utilizas, así te podemos ayudar a detectar el problema.

Saludos,
  #3 (permalink)  
Antiguo 04/06/2009, 04:47
Avatar de speedkill  
Fecha de Ingreso: mayo-2009
Ubicación: Graz
Mensajes: 30
Antigüedad: 14 años, 11 meses
Puntos: 1
Respuesta: Column `name`cannot be null

ahi va...

Código PHP:
<?php require_once('Connections/conexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "insertrecord")) {
  
$insertSQL sprintf("INSERT INTO tablamaestro (POS, `CODIGO INCIDENCIA`) VALUES (%s, %s)",
                       
GetSQLValueString($_POST['pos'], "text"),
                       
GetSQLValueString($_POST['codigo inci'], "text"));

  
mysql_select_db($database_conexion$conexion);
  
$Result1 mysql_query($insertSQL$conexion) or die(mysql_error());

  
$insertGoTo "maestro.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_conexion$conexion);
$query_Recordset1 "SELECT `CODIGO INCIDENCIA` FROM tablamaestro";
$Recordset1 mysql_query($query_Recordset1$conexion) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "httx://xxx.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="httx://xxxx.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Nueva Incidencia</title>
</head>

<body>
<form id="insertrecord" name="insertrecord" method="POST" action="<?php echo $editFormAction?>">
  <p>POS 
    <label><input name="pos" type="text" id="pos" size="50" /></label>
</p>
  <p>Codigo Incidencia 
    <label>
    <input name="codigo incidencia" type="text" id="codigo incidencia" size="15" />
    </label>
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Enviar" />
  </p>
  <input type="hidden" name="MM_insert" value="insertrecord" />
</form>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
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 08:29.