tengo un porblemita en una listado de productos y es q al listar coloco un boton donde me envia a una pagina para solo actualizar el campo "logo" d la tabla productos... pero no me esta agarrando el campo...
fijense asi envio desde el boton
act_logo_prod.php?=<?php echo $row_Recordset1['id']; ?>
y esta es la pagina donde tengo el form para actualizar ese campo en especifico
Código PHP:
<?php //require_once('includes/sesion.php'); ?>
<?php require_once('../Connections/alba.php'); ?>
<?php
include_once("fckeditor/fckeditor.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_update"])) && ($_POST["MM_update"] == "form2")) {
if ($_POST['opcion']==1){
$ediciondir= '../logo/';
$uploaddir=$ediciondir;
if (!is_dir($ediciondir)) { mkdir($uploaddir, 0777); }
move_uploaded_file($_FILES['logo2']['tmp_name'], $uploaddir . $_FILES['logo2']['name']);
$filename = $_FILES['logo2']['name'];}
else {
$filename = $_POST['logo'];
}
$updateSQL = sprintf("UPDATE productos SET logo=%s WHERE id=%s",
GetSQLValueString($filename, "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_alba, $alba);
$Result1 = mysql_query($updateSQL, $alba) or die(mysql_error());
$updateGoTo = "listado_prod.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = $_GET['id'];
}
mysql_select_db($database_alba, $alba);
$query_Recordset1 = sprintf("SELECT logo FROM productos WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $alba) 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" "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=utf-8" />
<title>Panel Administrativo</title>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('images/volver2.jpg')">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="header_admin.jpg" width="500" height="150" /></td>
</tr>
<tr>
<td><div align="center" class="textolistadoprod">Actualizar Logo de la Obra</div></td>
</tr>
<tr>
<td align="center"><table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2" enctype="multipart/form-data">
<br />
<table align="center">
<tr valign="baseline">
<td colspan="2" align="right" nowrap="nowrap"><span class="textoprincipal">Actualizar Logo? Si
<input name="opcion" type="radio" value="1" />
/No
<input name="opcion" type="radio" value="0" checked="checked" />
</span><span class="textoTitulos2">
<input name="logo" type="hidden" class="todopanel" value="<?php echo $row_Recordset1['logo']; ?>" size="32" />
</span> <span class="Estilo8"><span class="todopanel">
<input name="logo2" type="file" class="textoprincipal" id="logo2" />
</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" class="botones" value="Actualizar" /></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="hidden" name="MM_update" value="form2" />
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
<span class="textoprincipal"><?php echo $row_Recordset1['logo']; ?></span>
</form>
<p> </p></td>
</tr>
</table>
<table width="500" border="0" cellspacing="3" cellpadding="0">
<tr>
<td width="50%" align="center"><a href="index.php" target="_self"></a></td>
<td width="50%" align="right"><a href="index.php" target="_self"><img src="http://www.forosdelweb.com/images/volver1.jpg" name="Image1" width="57" height="11" border="0" id="Image1" onmouseover="MM_swapImage('Image1','','images/volver2.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
ah.. hice un echo adicional a ver si me estaba leyendo el campo y nada q ver!!!!
el error estaba al pasar el ID
act_logo_prod.php?=<?php echo $row_Recordset1['id']; ?> ERROR
act_logo_prod.php?id=<?php echo $row_Recordset1['id']; ?> Correcto