Foros del Web » Programando para Internet » PHP »

Urgente! Pierde Variable En Submit

Estas en el tema de Urgente! Pierde Variable En Submit en el foro de PHP en Foros del Web. EN este codigo me pasa lo mismo que en un post anterior, pierdo los valores de tanto como las cookies y como las variables $cualquiercosa. ...
  #1 (permalink)  
Antiguo 18/12/2004, 13:18
Avatar de gaitagarcia  
Fecha de Ingreso: julio-2002
Mensajes: 79
Antigüedad: 21 años, 8 meses
Puntos: 0
Urgente! Pierde Variable En Submit

EN este codigo me pasa lo mismo que en un post anterior, pierdo los valores de tanto como las cookies y como las variables $cualquiercosa.

Agradezco ayuda. en el codigo puse cuando veo la variable y cuando desaparece.

gracias
G


Código PHP:
<?php require_once('../Connections/bd_empresas.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{

/* errores de la pagina AQUI ES DONDE PIERDE LOS VALORES */ 

echo "var1";echo $row_clasif_a_borrar['id_usuario']; echo "VAR2"; echo $HTTP_COOKIE_VARS[usId]; echo "$HTTP_COOKIE_VARS[usNick]"; echo exit();

/* errores de la pagina AQUI ES DONDE PIERDE LOS VALORES */ 

  
$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(
$_GET['id_clasif'])) && ($_POST["MM_insert"] == "form1")) {
  
$deleteSQL sprintf("DELETE FROM clasificados WHERE id=%s",
                       
GetSQLValueString($_GET['id_clasif'], "int"));

  
mysql_select_db($database_bd_empresas$bd_empresas);
  
$Result1 mysql_query($deleteSQL$bd_empresas) or die(mysql_error());

  
$deleteGoTo "modificar_clasificado.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$deleteGoTo .= (strpos($deleteGoTo'?')) ? "&" "?";
    
$deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$deleteGoTo));
}
?>
<?php

mysql_select_db
($database_bd_empresas$bd_empresas);
$query_clasif_a_borrar sprintf("SELECT id, titulo, precio, fecha, id_usuario FROM clasificados WHERE id = $id_clasif"$colname_clasif_a_borrar);
$clasif_a_borrar mysql_query($query_clasif_a_borrar$bd_empresas) or die(mysql_error());
$row_clasif_a_borrar mysql_fetch_assoc($clasif_a_borrar);
$totalRows_clasif_a_borrar mysql_num_rows($clasif_a_borrar);

/* y aca si los tengoo que sera que pasa??? */
echo "http";echo $HTTP_COOKIE_VARS[usId]; echo "id_de_clasif_"; echo $row_clasif_a_borrar['id_usuario']; exit();
?>


<form name="form1" method="POST" action="<?php echo $editFormAction?>">
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="5" bgcolor="#FFFFFF"><img src="../img/spacer.gif" width="5" height="5"></td>
    <td width="986" valign="top"><table width="450" height="100%"  border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td height="17" colspan="4"><img src="../img/tit_clasificados.gif" width="450" height="17"></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="5" colspan="4"><img src="../img/spacer.gif" width="5" height="5"></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="1" colspan="4"><img src="../img/px_celeste.jpg" width="450" height="1"></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td width="1" height="100%" rowspan="2"><img src="../img/px_celeste.jpg" width="1" height="100%"></td>
        <td width="448" height="1" align="right"><img src="../img/spacer.gif" width="448" height="1"></td>
        <td width="50" height="100%" rowspan="2"><div align="left"><img src="../img/px_celeste.jpg" width="1" height="100%"></div></td>
        <td width="1" rowspan="2" align="right"><img src="../img/spacer.gif" width="5" height="1"></td>
      </tr>
      <tr>
        <td width="448" align="left" valign="top" bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="5" cellpadding="0">
          <tr>
            <td valign="top">
            <link href="../styles.css" rel="stylesheet" type="text/css">

<table  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td><span class="Estilo2"><img src="../img/spacer.gif" width="5" height="5" align="middle"></span> <span class="Estilo2"><img src="../img/spacer.gif" width="5" height="5" align="middle"></span><span class="titulos01">Modificar  Art&iacute;culo<br>
    </span>
      <div align="center">
      <table  border="0" align="center" cellpadding="0" cellspacing="0">
            <tr valign="middle">
              <td width="182"><img src="../img/px_blanco.jpg" width="1" height="5"></td>
              <td width="291"><input name="provincia" type="hidden" value="<?php echo $row_usuario['provincia']; ?>">
                <input name="localidad" type="hidden" value="<?php echo $row_usuario['localidad']; ?>">
                <input name="id_usuario" type="hidden" value="<?php echo $row_usuario['id']; ?>">
                <input name="visitas" type="hidden" value="0"></td>
            </tr>
            <tr valign="middle">
              <td height="25" colspan="2" class="ayudas"><p>ACLARACION: Pasados los 15 dias de vencido el Clasificado se iran eliminando de nuestra base de datos.<br>
                  Cuando la fecha se muestra en <span class="Estilo14">rojo</span> es por que expiro el tiempo del clasificado. Muchas Gracias </p>
                </td>
            </tr>
            <tr valign="middle">
              <td height="5" colspan="2" class="ayudas"><img src="../img/px_blanco.jpg" width="1" height="5"></td>
            </tr>
            <tr valign="middle">
              <td height="29" colspan="2">                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td colspan="6"><img src="../img/px_celeste.jpg" width="100%" height="1"></td>
                    </tr>
                  <tr>
                    <td width="1" height="100%"><img src="../img/px_celeste.jpg" width="1" height="100%"></td>
                    <td width="40" class="celda01"><span class="textos01"><div align="center" class="textos02">
    
        </div>
                    </span></td>
                    <td class="celda01"><span class="titulos01"><?php echo $row_clasif_a_borrar['titulo']; ?></span></td>
                    <td class="celda01"><div align="right"><span class="textos01">$&nbsp;<?php echo $row_clasif_a_borrar['precio']; ?></span></div></td>
                    <td width="10" class="textos03"><div align="right"></div></td>
                    <td width="1" height="100%"><img src="../img/px_celeste.jpg" width="1" height="100%"></td>
                  </tr>
                  <tr>
                    <td colspan="6"><img src="../img/px_celeste.jpg" width="100%" height="1"></td>
                  </tr>
                  <tr>
                    <td colspan="6"><img src="../img/px_blanco.jpg" width="1" height="5"></td>
                  </tr>
                              </table>
                </td>
              </tr>
            <tr valign="middle">
              <td height="29">&nbsp;</td>
              <td height="29">
                <div align="left">
                  Seguro desea eliminar?
                  <input name="Submit" type="submit" value="&nbsp;" style="width: 74; height: 18; border-style: solid; border-width: 0; padding: 0; background-image: url('../img/buscar.jpg')"><input type="hidden" name="MM_insert" value="form1">
                  <span class="titulos01"><span class="Estilo2"><img src="../img/spacer.gif" width="82" height="10"></span></span> </div></td>
            </tr>
          </table>
  
       
          <p align="left"><span class="titulos01">        </span></p>
      </div></td>
    </tr>
  <tr>
    <td valign="top"></td>
</table>

        
        
                   </td>
          </tr>
        </table>
   </td>
        </tr>
      <tr bgcolor="#FFFFFF">
        <td height="1" colspan="4"><img src="../img/px_celeste.jpg" width="450" height="1"></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="5" colspan="4"><img src="../img/spacer.gif" width="450" height="3"></td>
      </tr>
    </table></td>
  </tr>
</table>

</form>
<?php
mysql_free_result
($clasif_a_borrar);

mysql_free_result($verif_user);
?>
  #2 (permalink)  
Antiguo 18/12/2004, 22:26
Avatar de sism82  
Fecha de Ingreso: octubre-2003
Ubicación: Guadalajara
Mensajes: 865
Antigüedad: 20 años, 5 meses
Puntos: 1
a simple vista veo dos cosas incorrectas:

Código PHP:
$HTTP_COOKIE_VARS[usId]; 
Por principio de cuentas, ese arreglo no debería ser usado mas que en versiones previas a php 4.1, a partir de php 4.1 se recomienda el uso del arreglo asociativo $_COOKIE
Ahora bien, php soporta cosas que no son del todo correctas, pero eso puede traer errores 'raros'. Cuando utilizas un arreglo asociativo, la llave dentro delos corchetes debe ser un string, como tal, debe estar rodeado de comillas dobles o simples, es decir $_COOKIE['usId'];

saludos
  #3 (permalink)  
Antiguo 19/12/2004, 12:01
Avatar de gaitagarcia  
Fecha de Ingreso: julio-2002
Mensajes: 79
Antigüedad: 21 años, 8 meses
Puntos: 0
Continua el errror

Puse como me dijiste $_COOKIE['usId'] y me funciona perfecto. Ahora me podrias decir por queno me pasa el valor de esta variable
Código PHP:
$row_clasif_a_borrar['id_usuario']; 
lo que me parece raro es que cuando esta dentro de la funcion function
Código PHP:
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""

pierde el valor, incluso lleve la consula de la base de datos para arriba de todo cosa que si le igual la funcion antes de ejecutarla igual tenga valor y aun asi la pierde. Que puede ser que el boton de sumbit me borra esta variable? tambien te cuanto que e probado que al poner
Código PHP:
$HTTP_COOKIE_VARS[usId
al principio, igual me tira el resultado pero pasa lo mismo con el boton de submit me lo borra.

Agradeceria infromacion.
Atte
G
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.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:24.