Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2008, 11:41
MartaMad
 
Fecha de Ingreso: julio-2007
Mensajes: 75
Antigüedad: 16 años, 9 meses
Puntos: 0
No hace el update......

Hola tengo un update de una tabla, a la página le paso los campos de un formulario, y se forma bien la query (update) ya que la he capturado y la he ejecutado en phpmyadmin y todo ok!!!

El problema es que no se hacen los cambios cuando ejecuto mi código en web.... os pongo el código que tengo en el archivo modificar.php:
Código PHP:
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>DISTRIBUIDOR</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
<link href="imagenes/mm_entertainment.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#14285f">

<?
          
//conexión a la BBDD
$link = @mysql_pconnect("localhost""mibase""pass");
@
mysql_select_db("mibase"$link);

$pendiente "N";
$contacto "N";
$envpresen "N";
$compaq "N";
$devpaq "N";
$leidoguion "N";
$distribuidor "N";
$diremal "N";
$pagadopaq "N";
$correomal "N";
$comentario "N";

//Obtener las variables
$id =  (int)$_REQUEST["id"];
$nombre $_REQUEST["nombre"];
$apellido1 $_REQUEST["apellido1"];
$apellido2 $_REQUEST["apellido2"];
$calle $_REQUEST["calle"];
$numero $_REQUEST["numero"];
$localidad $_REQUEST["localidad"];
$cp $_REQUEST["cp"];
$pais $_REQUEST["pais"];
$telefono $_REQUEST["telefono"];
$movil $_REQUEST["movil"];
$email $_REQUEST["email"];


if (
$_REQUEST["pendiente"])$pendiente $_REQUEST["pendiente"];
if (
$_REQUEST["contacto"])$contacto $_REQUEST["contacto"];
if (
$_REQUEST["envpresen"])$envpresen $_REQUEST["envpresen"];
if (
$_REQUEST["compaq"])$compaq $_REQUEST["compaq"];
if (
$_REQUEST["devpaq"])$devpaq $_REQUEST["devpaq"];
if (
$_REQUEST["leidoguion"])$leidoguion $_REQUEST["leidoguion"];
if (
$_REQUEST["distribuidor"])$distribuidor $_REQUEST["distribuidor"];
if (
$_REQUEST["diremal"])$diremal $_REQUEST["diremal"];
if (
$_REQUEST["pagadopaq"])$pagadopaq $_REQUEST["pagadopaq"];
if (
$_REQUEST["correomal"])$correomal $_REQUEST["correomal"];

$comentario $_REQUEST["comentario"];
                        
                        
$link = @mysql_pconnect("****""*****""*******");
@
mysql_select_db("*****"$link);
                
                
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="02021e">
    <td colspan="2" rowspan="2" nowrap="nowrap"><img src="imagenes/mm_entertainment_image.jpg" alt="Header image" width="400" height="140" border="0" /></td>
    <td height="58" nowrap="nowrap" colspan="2" id="logo" valign="bottom">MEN&Uacute; DISTRIBUIDOR </td>
    <td width="499">&nbsp;</td>
  </tr>
  <tr bgcolor="02021E">
<td height="57" nowrap="nowrap" colspan="2" id="tagline" valign="top">&nbsp;</td>
    <td width="499">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="5"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="5" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

  <tr>
    <td colspan="5" id="dateformat">&nbsp;
      <div align="left"><br />      
        <br />
      </div></td>
  </tr>
  <tr>
    <td width="90" valign="top">
    
<?


$edad 
= (int)$edad;                        
$condiciones "SET nombre='$nombre',apellido1='$apellido1',apellido2='$apellido2',calle='$calle',numero='$numero',localidad='$localidad',ciudad='$ciudad',cp='$cp',pais='$pais',telefono='$telefono',movil='$movil',email='$email',edad='$edad',pendiente='$pendiente',devpaq='$devpaq',contacto='$contacto',leidoguion='$leidoguion',envpresen='$envpresen',distribuidor='$distribuidor',compaq='$compaq',diremal='$diremal',pagadopaq='$pagadopaq',correomal='$correomal',comentarios='$comentario' WHERE id=$id";
$subquery "UPDATE Clientes ".$condiciones;


$subresult=mysql_query($subquery);
$num_registros mysql_num_rows($subresult);
$hecho 0;
$hecho mysql_affected_rows();

echo 
"Query: ".$subquery;
echo 
"<br>Hecho: ".$hecho;
//echo "<br>Link: ".$link;



if ($hecho == 1) {


?>
    <table border="0" cellspacing="0" cellpadding="2" width="754">
        <tr>
          <td width="750" class="subHeader"> <h4>
          <SCRIPT LANGUAGE="javascript">

                    location.href = "index.php";
                </SCRIPT>
          
          Los registros han sido actualizados</h4></td>
        </tr>
        <tr>
          <td class="bodyText">&nbsp;</td>
        </tr>
      </table>
     
     
    <?

}    

        
mysql_free_result($result);
        
        
    
mysql_close();



exit;
?>
    
</table>


<br />
</body>
</html>
A ver si veis algo que ponga mal, todos los campos son varchar excepto edad que es int......


Un saludo y gracias de antemano!!!

Última edición por jam1138; 07/06/2008 a las 13:46