Hola estoy haciendo un administrador de contenido y tengo un par de problemas cuando lo subo al servidor, ya que en local me funciona ok
este es el error que me tira el navegador cuando intento , en este caso, editar un registro
Warning: Cannot modify header information - headers already sent by (output started at /home/global/public_html/web/ricambi/admin/editar_foto.php:3) in /home/global/public_html/web/ricambi/admin/editar_foto.php on line 52
esta es la linea qu eme trae problemas header(sprintf("Location: %s", $updateGoTo)); en el codigo la he señalado en rojo
este es mi codigo por si alguien necesita verlo
Código PHP:
<?php require_once('../Connections/ricambi_conecta.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_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE productos SET codigo=%s, nombre=%s, imagen=%s, descripcion=%s, disponible=%s WHERE id=%s",
GetSQLValueString($_POST['codigo'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['imagen'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['disponible'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_ricambi_conecta, $ricambi_conecta);
$Result1 = mysql_query($updateSQL, $ricambi_conecta) or die(mysql_error());
$updateGoTo = "adminRicambi.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
[COLOR="Red"]header(sprintf("Location: %s", $updateGoTo));[/COLOR]// este es el error
}
$colname_editar_produtos = "-1";
if (isset($_GET['id'])) {
$colname_editar_produtos = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_ricambi_conecta, $ricambi_conecta);
$query_editar_produtos = sprintf("SELECT * FROM productos WHERE id = %s", $colname_editar_produtos);
$editar_produtos = mysql_query($query_editar_produtos, $ricambi_conecta) or die(mysql_error());
$row_editar_produtos = mysql_fetch_assoc($editar_produtos);
$totalRows_editar_produtos = mysql_num_rows($editar_produtos);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>editar contenido</title>
<link href="../css/estilo_ricambi.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include("menu_banner.php"); ?>
<table width="727" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="2%"><img src="../img/1pix.gif" alt="px" width="14" height="1" /></td>
<td width="93%" valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="750"><img src="../piezas_template/arriba.gif" alt="abajo" width="703" height="9" /></td>
</tr>
<tr>
<td class="centro_body"><h1 align="center">Editar
<?php if (!$_FILES[archivo][name] ){?>
</h1>
<table width="499" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="95" height="274" rowspan="2"> </td>
<td width="406" align="left" valign="top" nowrap="nowrap"><form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?id=<?php echo $row_editar_produtos['id']; ?> " id="form1" enctype="multipart/form-data">
<div align="justify">
<p class="titles">PASO UNO </p>
<p class="titles"><img src="../img_producto/<?php echo $row_editar_produtos['imagen']; ?>" alt="<?php echo $row_editar_produtos['imagen']; ?>" /><span class="fondo_pie"><?php echo $row_editar_produtos['imagen']; ?></span></p>
<p><span class="texto_upload">Elige la imagen que deseas mostrar haciendo clic en<br />
examinar, los formatos permitidos son jpg y gif,<br />
luego de examinar la foto presiona enviar y la<br />
foto se subira al sitio automáticamente,si <br />
la subida es exitosa tu foto deberia aparecer aqui; <br /></span>
<input type="file" name="archivo" id="archivo"/>
<input type="submit" name="env" value="Enviar" id="env"/>
</p>
</div>
</form>
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<?php $foto=$_FILES[archivo][name];
?>
</tr>
</table></td>
</tr>
<tr>
<td height="2" align="left" valign="top" nowrap="nowrap"></td>
</tr>
</table>
<p>
<?php }?>
<?php if(isset($_POST[env])&& $_POST[env]<>""){
$permitidos=array("jpg","JPG","jpeg","JPEG","gif");
$archivo=$_FILES[archivo][name];
$separa = explode (".",$archivo);
$ext=$separa[1];
$nombre_archivo = "../img_producto/".$archivo;
if(file_exists($nombre_archivo)){
echo "<br><br><br><span class = 'texto_upload_wrong'>El nombre del archivo ya existe,
intenta cambiarle el nombre a la imagen<br></span><a href=javascript:history.back(-1);>Reintentar</a><br><br><br><br><br>";
}else{
if(!in_array($ext,$permitidos)){
echo "<br><br><br><span class = 'texto_upload_wrong'>El formato no es permitido, solo se permite formato JPG
intenta cambiarle la extension a tu foto,
si no sabes como hacerlo comunicate con nosotros
y te ayudaremos<br></span><a href=javascript:history.back(-1);>Volver</a><br>";
$tamano_max=500000;
if($_FILES[archivo][size]>$tamano_max){
$error="el tamaño exede ".$_FILES[archivo][name];
echo $error;
}
}else{
if(!$error){
if(@move_uploaded_file($_FILES[archivo][tmp_name],$_SERVER['DOCUMENT_ROOT']."/web/ricambi/img_producto/".$_FILES[archivo][name])){
//if(@move_uploaded_file($_FILES[archivo][tmp_name],$_SERVER['DOCUMENT_ROOT']."/ricambi/img_producto/".$_FILES[archivo][name])){
$exito="<span class='texto_upload'>tu foto se envio exitosamente,<br>
ahora llena los campos del formulario
y haz clic en el boton enviar</span><br>";
echo $exito;?>
</p>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right"><img src="../img_producto/<?php echo $_FILES[archivo][name]?>" alt="<?php echo $_FILES[archivo][name]?>" width="139" height="141" /></td>
<td><input type="submit" value="Actualizar registro"></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $row_editar_produtos['id']; ?>">
<input type="hidden" name="codigo" value="<?php echo $row_editar_produtos['codigo']; ?>">
<input type="hidden" name="nombre" value="<?php echo $row_editar_produtos['nombre']; ?>">
<input type="hidden" name="imagen" value="<?php echo $_FILES[archivo][name]?>">
<input type="hidden" name="descripcion" value="<?php echo $row_editar_produtos['descripcion']; ?>">
<input type="hidden" name="disponible" value="<?php echo $row_editar_produtos['disponible']; ?>">
<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="id" value="<?php echo $row_editar_produtos['id']; ?>">
</form>
<p> </p>
<p>
<?php echo "<b>nombre</b> ".$_FILES[archivo][name]."\n"." <b>peso</b> ".$_FILES[archivo][size] ?>
<br />
<?php }
}
}
}
}
?>
</p>
<p> </p></td>
</tr>
<tr>
<td><img src="../piezas_template/abajo.gif" alt="arriba" width="703" height="14" /></td>
</tr>
</table></td>
<td width="5%" class="borde_der"><img src="../img/1pix.gif" alt="px" width="20" height="1" /></td>
</tr>
</table>
<?php include("pie.php"); ?>
<p> </p>
</body>
</html>
<?php
mysql_free_result($editar_produtos);
?>
gracias