Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/11/2015, 11:03
ingridquevedoa
 
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);
?>