Foros del Web » Programando para Internet » PHP »

SOLUCIONADO - Actualizar un solo campo desde php

Estas en el tema de SOLUCIONADO - Actualizar un solo campo desde php en el foro de PHP en Foros del Web. Saludos, tengo un porblemita en una listado de productos y es q al listar coloco un boton donde me envia a una pagina para solo ...
  #1 (permalink)  
Antiguo 19/08/2008, 11:57
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
SOLUCIONADO - Actualizar un solo campo desde php

Saludos,
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($uploaddir0777);    }
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">&nbsp;</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>&nbsp;</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>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
saludos y gracias...

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
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...

Última edición por T4ke0veR; 19/08/2008 a las 13:07
  #2 (permalink)  
Antiguo 19/08/2008, 12:51
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Actualizar un solo campo desde php

barbaro nadie lo lee.. si alguien lo ve, por favor es lo unico q me falta para culminar!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #3 (permalink)  
Antiguo 19/08/2008, 22:04
Avatar de enriqueplace  
Fecha de Ingreso: mayo-2005
Ubicación: Uruguay / Argentina
Mensajes: 1.102
Antigüedad: 18 años, 11 meses
Puntos: 32
Respuesta: Actualizar un solo campo desde php

Cita:
Iniciado por T4ke0veR Ver Mensaje
barbaro nadie lo lee.. si alguien lo ve, por favor es lo unico q me falta para culminar!!!
Si no resumes tu pregunta, difícilmente alguien se tome el tiempo de responderla.
__________________
Blog phpsenior.com Cursos a Distancia surforce.com
  #4 (permalink)  
Antiguo 19/08/2008, 22:41
Avatar de nicolyto77  
Fecha de Ingreso: marzo-2007
Ubicación: Buenos Aires
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 12
Respuesta: SOLUCIONADO - Actualizar un solo campo desde php

Holas

¿Que hace? ¿No te actualiza el campo? ¿El ID no llega?

Si das mas datos por ahi te pueda ayudar en algo...

Saludos
__________________
CabaSoft Networks
  #5 (permalink)  
Antiguo 19/08/2008, 22:44
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: SOLUCIONADO - Actualizar un solo campo desde php

El titulo del tema dice Solucionado.
Parece que el ya lo soluciono. Pero no posteo como.
  #6 (permalink)  
Antiguo 19/08/2008, 22:47
Avatar de nicolyto77  
Fecha de Ingreso: marzo-2007
Ubicación: Buenos Aires
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 12
Respuesta: SOLUCIONADO - Actualizar un solo campo desde php

Si, perdon por responder, pero como vi el tema encima del mio creado hoy mismo, pense que estaba vivo aun.

Saludos
__________________
CabaSoft Networks
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.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 09:41.