Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] PHP OO Column 'usuario' cannot be null

Estas en el tema de Column 'usuario' cannot be null en el foro de PHP en Foros del Web. Hola a todos, Mi nombre es Ingrid y acabo de inscribirme a esta pagina y a la vez soy nueva en todo lo que tiene ...
  #1 (permalink)  
Antiguo 24/11/2015, 10:54
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Pregunta Column 'usuario' cannot be null

Hola a todos,

Mi nombre es Ingrid y acabo de inscribirme a esta pagina y a la vez soy nueva en todo lo que tiene que ver con programacion, en estos momentos me toca hacer una aplicacion para guardar unos contratos de la empresa, la empresa ya tenia uno y lo que hice fue unos cambios sobre la misma, pero al dar aceptar para que guarde el registro , me aparece en una pantalla en blanco la frase: Column 'usuario' cannot be null

En la base de datos tengo creado usuario, y en el codigo tambien esta usuario, la verdad no se que esta mal

Agradezco mucho su colaboracion
  #2 (permalink)  
Antiguo 24/11/2015, 10:58
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Column 'usuario' cannot be null

Cita:
la verdad no se que esta mal
Y nosotros tampoco vamos a adivinar.

Recuerda que estás en un foro técnico y si no muestras tu código ¿qué se le puede hacer?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 24/11/2015, 11:03
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

<?php require_once('../../Connections/comercio_electronico.php'); ?>
<?php
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO grupos_contratos (usuario, fecha_ingreso, codigo, compania, fecha_inicio, observaciones,hotel) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['fecha_ingreso'], "text"),
GetSQLValueString($_POST['codigo'], "text"),
GetSQLValueString($_POST['compania'], "text"),
GetSQLValueString($_POST['fecha_inicio'], "text"),
GetSQLValueString($_POST['observaciones'], "text"),
GetSQLValueString($_POST['hotel'], "text"));

mysql_select_db($database_comercio_electronico, $comercio_electronico);
$Result1 = mysql_query($insertSQL, $comercio_electronico) or die(mysql_error());

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

$currentPage = $_SERVER["PHP_SELF"];

$colname_user = "-1";
if (isset($_SESSION['usuario'])) {
$colname_user = $_SESSION['usuario'];
}
mysql_select_db($database_comercio_electronico, $comercio_electronico);
$query_user = sprintf("SELECT * FROM grupos_usuarios WHERE usuario = %s", GetSQLValueString($colname_user, "text"));
$user = mysql_query($query_user, $comercio_electronico) or die(mysql_error());
$row_user = mysql_fetch_assoc($user);
$totalRows_user = mysql_num_rows($user);


?>
<?php
if (isset($_SESSION['usuario'])){
if($row_user['nombre']==NULL){
header('Location: login.php');
}else{
}
}else{
header('Location: login.php');
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Compras - Contratos</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #EAEAEA;
}
-->
</style>
<link href="../../css/clases.css" rel="stylesheet" type="text/css" />
<link href="../../css/evo_mew.css" rel="stylesheet" type="text/css" />
<link href="../../css/styles_new.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {color: #FFFFFF; }
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: underline;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #FF0000;
}
-->
</style>
<script src="../../js/jquery-1.4.4.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../../css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
<script src="../../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
<script language="JavaScript">
//Código para colocar
//los indicadores de miles mientras se escribe
//script por tunait!
function puntitos(donde,caracter)
{
pat = /[\*,\+,\(,\),\?,\\,\$,\[,\],\^]/
valor = donde.value
largo = valor.length
crtr = true
if(isNaN(caracter) || pat.test(caracter) == true)
{
if (pat.test(caracter)==true)
{caracter = "\\" + caracter}
carcter = new RegExp(caracter,"g")
valor = valor.replace(carcter,"")
donde.value = valor
crtr = false
}
else
{
var nums = new Array()
cont = 0
for(m=0;m<largo;m++)
{
if(valor.charAt(m) == "." || valor.charAt(m) == " ")
{continue;}
else{
nums[cont] = valor.charAt(m)
cont++
}

}
}


var cad1="",cad2="",tres=0
if(largo > 3 && crtr == true)
{
for (k=nums.length-1;k>=0;k--)
{
cad1 = nums[k]
cad2 = cad1 + cad2
tres++
if((tres%3) == 0)
{
if(k!=0){
cad2 = "." + cad2
}
}
}
donde.value = cad2
}
}
</script>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle"><div align="center">
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="700" border="1">
<tr>
<td colspan="2" align="right">[<a href="contratosg.php">Volver</a>]</td>
</tr>
<tr>
<td width="204">Codigo</td>
<td width="486"><input name="codigo" type="text" id="codigo" size="50" required></td>
</tr>
<tr>
<td>Compania</td>
<td><input name="codigo" type="text" id="codigo" size="50" required></td>
</tr>

<tr>
<td>Fecha de Inicio</td>
<td><input type="date" name="fecha_inicio" id="fecha_inicio" required></td>
</tr>



<tr>
<td valign="top">Observaciones</td>
<td><textarea name="observaciones" id="observaciones" cols="45" rows="5"></textarea></td>
</tr>

<tr>
<td>Hotel</td>
<td><select name="hotel" id="hotel">

<option value="Hotel Buro 26">Movich Buro 26</option>
<option value="Hotel Buro 51">Movich Buro 51</option>
<option value="Hotel Cartagena de Indias">Movich Cartagena de Indias</option>
<option value="Hotel Las Lomas">Movich Las Lomas</option>
<option value="Hotel de Pereira">Movich de Pereira</option>
<option value="Hotel InterContinental Medellin">Movich InterContinental de Medellin</option>
<option value="Hotel Movich Chico 97">Movich Chico 97</option>
<option value="Hotel Movich Casa del Alf&eacute;rez">Movich Casa del Alferez</option>
</select></td>
</tr>


<tr>
<td colspan="2" align="center"><input type="submit" name="button" id="button" value="Agregar"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($user);
mysql_free_result($compania);
?>
  #4 (permalink)  
Antiguo 24/11/2015, 11:06
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

gracias y que pena por no enviarlo
  #5 (permalink)  
Antiguo 24/11/2015, 11:12
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Column 'usuario' cannot be null

Por favor edita tu mensaje y usa las herramientas de resaltado de sintaxis, es complicado (y molesto) leer código sin formato.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #6 (permalink)  
Antiguo 24/11/2015, 11:18
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Código PHP:
<?php require_once('../../Connections/comercio_electronico.php'); ?>
<?php
session_start
();
if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO grupos_contratos (usuario, fecha_ingreso, codigo, compania, fecha_inicio, observaciones,hotel) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['usuario'], "text"),
                       
GetSQLValueString($_POST['fecha_ingreso'], "text"),
                       
GetSQLValueString($_POST['codigo'], "text"),
                       
GetSQLValueString($_POST['compania'], "text"),
                       
GetSQLValueString($_POST['fecha_inicio'], "text"),
                       
GetSQLValueString($_POST['observaciones'], "text"),
                       
GetSQLValueString($_POST['hotel'], "text"));

  
mysql_select_db($database_comercio_electronico$comercio_electronico);
  
$Result1 mysql_query($insertSQL$comercio_electronico) or die(mysql_error());

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

$currentPage $_SERVER["PHP_SELF"];

$colname_user "-1";
if (isset(
$_SESSION['usuario'])) {
  
$colname_user $_SESSION['usuario'];
}
mysql_select_db($database_comercio_electronico$comercio_electronico);
$query_user sprintf("SELECT * FROM grupos_usuarios WHERE usuario = %s"GetSQLValueString($colname_user"text"));
$user mysql_query($query_user$comercio_electronico) or die(mysql_error());
$row_user mysql_fetch_assoc($user);
$totalRows_user mysql_num_rows($user);


?>
<?php
if (isset($_SESSION['usuario'])){
     if(
$row_user['nombre']==NULL){
     
header('Location: login.php');
     }else{
     }
}else{
      
header('Location: login.php');
}
      
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Compras - Contratos</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #EAEAEA;
}
-->
</style>
<link href="../../css/clases.css" rel="stylesheet" type="text/css" />
<link href="../../css/evo_mew.css" rel="stylesheet" type="text/css" />
<link href="../../css/styles_new.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {color: #FFFFFF; }
a:link {
    color: #FF0000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FF0000;
}
a:hover {
    text-decoration: underline;
    color: #FF0000;
}
a:active {
    text-decoration: none;
    color: #FF0000;
}
-->
</style>
<script src="../../js/jquery-1.4.4.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../../css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
        <script src="../../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
<script language="JavaScript">
//Código para colocar 
//los indicadores de miles mientras se escribe
//script por tunait!
function puntitos(donde,caracter)
{
pat = /[\*,\+,\(,\),\?,\\,\$,\[,\],\^]/
valor = donde.value
largo = valor.length
crtr = true
if(isNaN(caracter) || pat.test(caracter) == true)
    {
    if (pat.test(caracter)==true) 
        {caracter = "\\" + caracter}
    carcter = new RegExp(caracter,"g")
    valor = valor.replace(carcter,"")
    donde.value = valor
    crtr = false
    }
else
    {
    var nums = new Array()
    cont = 0
    for(m=0;m<largo;m++)
        {
        if(valor.charAt(m) == "." || valor.charAt(m) == " ")
            {continue;}
        else{
            nums[cont] = valor.charAt(m)
            cont++
            }
        
        }
    }


var cad1="",cad2="",tres=0
if(largo > 3 && crtr == true)
    {
    for (k=nums.length-1;k>=0;k--)
        {
        cad1 = nums[k]
        cad2 = cad1 + cad2
        tres++
        if((tres%3) == 0)
            {
            if(k!=0){
                cad2 = "." + cad2
                }
            }
        }
     donde.value = cad2
    }
}    
</script>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="middle"><div align="center">
      <form name="form1" method="POST" action="<?php echo $editFormAction?>">
        <table width="700" border="1">
          <tr>
            <td colspan="2" align="right">[<a href="contratosg.php">Volver</a>]</td>
            </tr>
          <tr>
            <td width="204">Codigo</td>
            <td width="486"><input name="codigo" type="text" id="codigo" size="50" required></td>
          </tr>
          <tr>
            <td>Compania</td>
            <td><input name="codigo" type="text" id="codigo" size="50" required></td>
          </tr>
         
          <tr>
            <td>Fecha de Inicio</td>
            <td><input type="date" name="fecha_inicio" id="fecha_inicio" required></td>
          </tr>
         
          
          
          <tr>
            <td valign="top">Observaciones</td>
            <td><textarea name="observaciones" id="observaciones" cols="45" rows="5"></textarea></td>
          </tr>
          
          <tr>
            <td>Hotel</td>
            <td><select name="hotel" id="hotel">
            
              <option value="Hotel Buro 26">Movich Buro 26</option>
              <option value="Hotel Buro 51">Movich Buro 51</option>
              <option value="Hotel Cartagena de Indias">Movich Cartagena de Indias</option>
              <option value="Hotel Las Lomas">Movich Las Lomas</option>
              <option value="Hotel de Pereira">Movich de Pereira</option>
              <option value="Hotel InterContinental Medellin">Movich InterContinental de Medellin</option>
              <option value="Hotel Movich Chico 97">Movich Chico 97</option>
              <option value="Hotel Movich Casa del Alf&eacute;rez">Movich Casa del Alferez</option>
            </select></td>
          </tr>
          
          
          <tr>
            <td colspan="2" align="center"><input type="submit" name="button" id="button" value="Agregar"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_insert" value="form1">
      </form>
    </div></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($user);
mysql_free_result($compania);
?>
  #7 (permalink)  
Antiguo 24/11/2015, 11:19
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

espero asi si este bn, que pena , como digo es la primera vez que ingreso a todo esto
  #8 (permalink)  
Antiguo 24/11/2015, 15:01
 
Fecha de Ingreso: noviembre-2003
Ubicación: Zaragoza, España
Mensajes: 1.257
Antigüedad: 20 años, 5 meses
Puntos: 154
Respuesta: Column 'usuario' cannot be null

Hola ingridquevedoa,

Así a ojo, lo que creo que te ocurre es que en la creación de la tabla en la base de datos, está puesto que el campo usuario no puede ser nulo (usuario... NOT NULL), entonces, te toca o bien validar que no te lo envíen vacío o quitar el NOT NULL de la tabla.

Espero que te sirva.
  #9 (permalink)  
Antiguo 24/11/2015, 15:25
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

hola,

Asi esta configurada la tabla

Estructura de tabla para la tabla `grupos_contratos`
--

CREATE TABLE IF NOT EXISTS `grupos_contratos` (
`codigo` int(11) NOT NULL AUTO_INCREMENT,
`usuario` varchar(200) NOT NULL,
`fecha_ingreso` varchar(100) NOT NULL,
`compania` varchar(200) DEFAULT NULL,
`hotel` varchar(200) DEFAULT NULL,
`fecha_inicio` varchar(100) DEFAULT NULL,
`observaciones` text,
PRIMARY KEY (`codigo`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

************************************************** *************
Quite el not null y me sale el mismo error
************************************************** **
Se tiene otra base de datos donde se colocan los usuarios que pueden ingresar a esa pagina, al ingresar ,abre la pagina para ingresar los contratos. y donde ingresan los contratos solo están los item:


Codigo
Compañia
Fecha de inicio
observaciones
Hotel


Gracias
  #10 (permalink)  
Antiguo 24/11/2015, 16:13
 
Fecha de Ingreso: noviembre-2003
Ubicación: Zaragoza, España
Mensajes: 1.257
Antigüedad: 20 años, 5 meses
Puntos: 154
Respuesta: Column 'usuario' cannot be null

Hola ,

Para empezar, prueba a ejecutar esta consulta en el PhPMyAdmin y vuelve a ver si te sigue dando el error:

Código SQL:
Ver original
  1. ALTER TABLE `grupos_contratos` CHANGE `usuario` `usuario` VARCHAR( 200 ) NULL ;

Por otra parte, en tu formulario no aparece por ningún sitio el campo usuario ¿de donde viene esto?:

Código PHP:
Ver original
  1. GetSQLValueString($_POST['usuario'], "text")

Revisa esas cosas y nos cuentas...
  #11 (permalink)  
Antiguo 25/11/2015, 03:05
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Column 'usuario' cannot be null

Saludo.
Aparte de lo que ya te mencionaron, en el formulario tienes el campo código y el campo compañía,
pero ambos inputs se llaman igual, y así a la hora de guardar lo digitado en el campo código no se guardará,
y en su lugar se guardará lo digitado en el campo compañía.

La solución es darles names e ids distintos,
como están los demás campos del formulario.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #12 (permalink)  
Antiguo 25/11/2015, 07:35
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Muchas gracias, voy a revisar y les comento
  #13 (permalink)  
Antiguo 25/11/2015, 08:17
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Hola me funciono muy bien , de acuerdo a los cambios que me dijeron mortiprogramador y rbczgz :), una pregunta adicional, si quiero que al ingresar los contratos en el formulario, el código aparezca automáticamente , auto incrementando, si se puede hacer]? que el mismo codigo que esta en phpmyadmin sea el mismo que aparezca en el formulario.

Gracias
  #14 (permalink)  
Antiguo 25/11/2015, 08:57
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Column 'usuario' cannot be null

Saludo.
Sí es posible, hay varias maneras de realizarlo,
una sencilla podría ser hacer un query antes
y consultar el MAX id de la tabla, al resultado sumarle uno
y este valor resultante asignarlo a donde se quiera mostrar.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #15 (permalink)  
Antiguo 27/11/2015, 07:57
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Muchas gracias :)
  #16 (permalink)  
Antiguo 27/11/2015, 09:14
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

hola mortiprogramador, que pena contigo pero no he podido hacer eso, habria alguna posibilidad que me dijeras como es en codigo o al menos un ejemplo, por favor, como digo soy principiante en esto de programacion y no se mucho .

Gracias
  #17 (permalink)  
Antiguo 27/11/2015, 11:15
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Column 'usuario' cannot be null

Saludo.
Podría ser algo así:

Código PHP:
Ver original
  1. $query = 'SELECT MAX(id) FROM tabla';
  2. $rs = mysql_query($query);
  3. $max = mysql_fetch_array($rs);
  4. $max = $max[0] + 1;
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #18 (permalink)  
Antiguo 27/11/2015, 11:36
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Muchas gracias :)
  #19 (permalink)  
Antiguo 27/11/2015, 12:00
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

uds saben porque me aparece este error? ...

dataTables warning (table id= 'example'): Requested unknown parameter '8' from the data source for row 0
  #20 (permalink)  
Antiguo 27/11/2015, 12:08
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Column 'usuario' cannot be null

Saludo.
Uhm, pues pareciera que o es una tabla o un campo que no existe,
hacerle un echo al query que se està ejecutando y llevarlo
a la herramienta donde se administra la bd y ejecutarlo allà
para ver que màs info muestra.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #21 (permalink)  
Antiguo 03/12/2015, 09:22
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Hola,
Estuve revisando y encontre la tabla que menciona el error dataTables warning (table id= 'example'): Requested unknow parameter '8' from the data source for row 0

este es el codigo
Código PHP:
if (isset($_SESSION['usuario'])){
     if($row_user['nombre']==NULL){
     header('Location: login.php');
     }else{
     }
}else{
      header('Location: login.php');
}
      ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Grupos - Contratos</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #EAEAEA;
}
-->
</style>
<link href="../../css/clases.css" rel="stylesheet" type="text/css" />
<link href="../../css/evo_mew.css" rel="stylesheet" type="text/css" />
<link href="../../css/styles_new.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {color: #FFFFFF; }
a:link {
    color: #FF0000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FF0000;
}
a:hover {
    text-decoration: underline;
    color: #FF0000;
}
a:active {
    text-decoration: none;
    color: #FF0000;
}
-->
</style>

<style type="text/css" title="currentStyle">
            @import "media/css/demo_page.css";
            @import "media/css/jquery.dataTables.css";
        </style>
        <script type="text/javascript" language="javascript" src="media/js/jquery.js"></script>
        <script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                $('#example').dataTable();
            } );
        </script>
        <script src="../../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
<script language="JavaScript">
function pregunta(){
    return confirm('¿Estas seguro de borrar este contrato y todos sus adjuntos?'); 
}
</script> 
</head>

<body>
<?PHP 
if($row_user['tipo']==1){?>
<table width="1100" border="0" align="center">
  <tr>
    <td><table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="1100">
      <thead>
        <tr>
          <th colspan="2">[<a href="agregar_contratosg.php">Agregar Contrato</a>]</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
          <th>&nbsp;</th>
        </tr>
        <tr>
          <th >Codigo</th>
          <th >Nombre_compa&ntilde;ia</th>
          <th >Fecha_Inicio</th>
          <th>Observaciones</th>
          <th>Hotel</th>
          <th>Modificar</th>
          <th>Adjuntos</th>
          <th>Eliminar</th>
        </tr>
      </thead>
      <tbody>
        <?php do { ?>
            <?php if ($totalRows_contratos 0) {// Show if recordset not empty ?>
            
  <tr class="odd gradeX">
    <td class="center"><?php echo $row_contratos['codigo']; ?></td>
    <td class="center"><?php echo $row_contratos['compania']; ?></td>
    <td class="center"><?php echo $row_contratos['fecha_inicio']; ?></td>
    <td class="center"><?php echo $row_contratos['observaciones']; ?></td>
    <td class="center"><?php echo $row_contratos['hotel']; ?></td>
    
 
    <td class="center"><a href="modificar_contratog.php?insert=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.0&id=<?php echo $row_contratos['codigo']; ?>&ola=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187"><img src="../../images/icon/icono_cambiar_clave.gif" width="32" height="32" border="0"></a></td>
    <td class="center"><a href="adjuntosg.php?insert=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.0&id_contrato=<?php echo $row_contratos['codigo']; ?>&ola=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187"><img src="../../images/icon/ampliacion_digitalizacion.png" width="32" border="0"></a></td>
    <td class="center"><form id="form1" name="form1" method="post" action="borrar_contratosg.php" ONSUBMIT="return pregunta();">
      <input name="codigo" type="hidden" id="codigo" value="<?php echo $row_contratos['codigo']; ?>">
      <input name="image" type=image  src="../../img/icons/fail.gif" width="16" height="16" />
    </form></td>
  </tr>
  <?php // Show if recordset not empty ?>
<?php 
} while ($row_contratos mysql_fetch_assoc($contratos)); ?>
      </tbody>
      <tfoot>
      </tfoot>
    </table></td>
  </tr>
</table>
<?PHP 
}else{?>
<table width="1100" border="0" align="center">
  <tr>
    <td><table cellpadding="0" cellspacing="0" border="0" class="display" id="example2" width="1100">
      <thead>
        <tr>
          <th colspan="2">[<a href="agregar_contratosg.php">Agregar Contrato</a>]</th>
          
        </tr>
        <tr>
          <th width="151">Codigo</th>
          <th width="206">Nombre compa&ntilde;ia</th>
          <th>Fecha</th>
          <th>Observaciones</th>
          <th>Hotel</th>
          <th>Modificar</th>
          <th>Adjuntos</th>
        </tr>
      </thead>
      <tbody>
        <?php do { ?>
        <?php if ($totalRows_contratos 0) { // Show if recordset not empty ?>
        <tr class="odd gradeX">
          <<td><?php echo $row_contratos['codigo']; ?></td>
          <td><?php echo $row_contratos['compania']; ?></td>
         
          <td class="center"><?php echo $row_contratos['fecha_inicio']; ?></td>
          <td class="center"><?php echo $row_contratos['observaciones']; ?></td>
          <td class="center"><?php echo $row_contratos['hotel']; ?></td>
         
     
          <td class="center"><a href="modificar_contratog.php?insert=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.0&id=<?php echo $row_contratos['codigo']; ?>&ola=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187"><img src="../../images/icon/icono_cambiar_clave.gif" width="32" height="32" border="0"></a></td>
          <td class="center"><a href="adjuntosg.php?insert=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.0&id_contrato=<?php echo $row_contratos['codigo']; ?>&ola=0j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187.9.9.0.0.0.0.178.1044.4j5.9.00j0i30j0i5i30l2.1485.4038.0.4187"><img src="../../images/icon/ampliacion_digitalizacion.png" width="32" border="0"></a></td>
        </tr>
        <?php // Show if recordset not empty ?>
        <?php } while ($row_contratos mysql_fetch_assoc($contratos)); ?>
      </tbody>
      <tfoot>
      </tfoot>
    </table></td>
  </tr>
</table>
<?PHP 
}?>
<p>[<a href="menug.php">Volver</a>]</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result
($contratos);
?>
De acuerdo al error, hay una tabla que se llama example la cual se encuentra en el codigo, en la parte donde dice
Código PHP:
 <?php do { ?>
            <?php if ($totalRows_contratos 0) {// Show if recordset not empty ?>
            
  <tr class="odd gradeX">
    <td class="center"><?php echo $row_contratos['codigo']; ?></td>
    <td class="center"><?php echo $row_contratos['compania']; ?></td>
    <td class="center"><?php echo $row_contratos['fecha_inicio']; ?></td>
    <td class="center"><?php echo $row_contratos['observaciones']; ?></td>
    <td class="center"><?php echo $row_contratos['hotel']; ?></td>
ese 0 que esta después de contratos > lo cambio por un 1, pero al hacer eso, el primer archivo que ingreso al programa, no se observa y al ingresar un segundo archivo ya me aparecen los dos.

No se que debo cambiar,

Gracias
  #22 (permalink)  
Antiguo 03/12/2015, 10:14
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Column 'usuario' cannot be null

Ya lo encontre, era un codigo en java :)

Etiquetas: mysql
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 20:39.