Cannot modify header information - header
Publicado por sandra (60 intervenciones) el 26/06/2007 13:13:46
Hola al actualiar registros me sale este error en pantalla:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/josemaria/gestoractualizar.php:62) in /var/www/josemaria/gestoractualizar.php on line 656
MI CODIGO ES ESTE:
<?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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE flores SET `ref`=%s, `desc`=%s, precio=%s, disp=%s, exist=%s, foto=%s WHERE num=%s",
GetSQLValueString($_POST['ref'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_POST['disp'], "text"),
GetSQLValueString($_POST['exist'], "int"),
GetSQLValueString($_POST['foto'], "text"),
GetSQLValueString($_POST['num'], "int"));
mysql_select_db($database_conexionjosemaria, $conexionjosemaria);
$Result1 = mysql_query($updateSQL, $conexionjosemaria) or die(mysql_error());
$updateGoTo = "./muestraoferta.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO flores (`ref`, `desc`, precio, disp, exist, foto) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ref'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_POST['disp'], "text"),
GetSQLValueString($_POST['exist'], "double"),
GetSQLValueString($_POST['foto'], "text"));
//tomo el valor de un elemento de tipo texto del formulario
$foto = $_POST["foto"];
echo "Referencia: " . $foto . "<br><br>";
//datos del arhivo
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
//compruebo si las características del archivo son las que deseo
if (!((strpos($tipo_archivo, "gif") || strpos($tipo_archivo, "jpeg")) && ($tamano_archivo < 2000000))) {
echo "La extensión o el tamaño de los archivos no es correcta. <br><br><table><tr><td><li>Se permiten archivos .gif o .jpg<br><li>se permiten archivos de 100 Kb máximo.</td></tr></table>";
}else{
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], "/var/www/upload/$nombre_archivo")){
echo "El archivo ha sido cargado correctamente.";
}else{
echo "Ocurrió algún error al subir el fichero. No pudo guardarse.";
}
}
mysql_select_db($database_conexionjosemaria, $conexionjosemaria);
$Result1 = mysql_query($insertSQL, $conexionjosemaria) or die(mysql_error());
}
?>
Warning: Cannot modify header information - headers already sent by (output started at /var/www/josemaria/gestoractualizar.php:62) in /var/www/josemaria/gestoractualizar.php on line 656
MI CODIGO ES ESTE:
<?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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE flores SET `ref`=%s, `desc`=%s, precio=%s, disp=%s, exist=%s, foto=%s WHERE num=%s",
GetSQLValueString($_POST['ref'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_POST['disp'], "text"),
GetSQLValueString($_POST['exist'], "int"),
GetSQLValueString($_POST['foto'], "text"),
GetSQLValueString($_POST['num'], "int"));
mysql_select_db($database_conexionjosemaria, $conexionjosemaria);
$Result1 = mysql_query($updateSQL, $conexionjosemaria) or die(mysql_error());
$updateGoTo = "./muestraoferta.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO flores (`ref`, `desc`, precio, disp, exist, foto) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ref'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_POST['disp'], "text"),
GetSQLValueString($_POST['exist'], "double"),
GetSQLValueString($_POST['foto'], "text"));
//tomo el valor de un elemento de tipo texto del formulario
$foto = $_POST["foto"];
echo "Referencia: " . $foto . "<br><br>";
//datos del arhivo
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
//compruebo si las características del archivo son las que deseo
if (!((strpos($tipo_archivo, "gif") || strpos($tipo_archivo, "jpeg")) && ($tamano_archivo < 2000000))) {
echo "La extensión o el tamaño de los archivos no es correcta. <br><br><table><tr><td><li>Se permiten archivos .gif o .jpg<br><li>se permiten archivos de 100 Kb máximo.</td></tr></table>";
}else{
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], "/var/www/upload/$nombre_archivo")){
echo "El archivo ha sido cargado correctamente.";
}else{
echo "Ocurrió algún error al subir el fichero. No pudo guardarse.";
}
}
mysql_select_db($database_conexionjosemaria, $conexionjosemaria);
$Result1 = mysql_query($insertSQL, $conexionjosemaria) or die(mysql_error());
}
?>
Valora esta pregunta


0