Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/08/2007, 09:29
persi
 
Fecha de Ingreso: agosto-2007
Mensajes: 25
Antigüedad: 16 años, 9 meses
Puntos: 0
Problemas con el update

Hola! Tengo un problema con el update y por más que lo miro no se que puede ser.

Resulta que siempre que realizo el update no me modifica la base de datos y me da el mensaje del "or die(No se ha realizado la actualización");". Alguien sabe porque puede ser?

Aqui va el código:
Código PHP:
<?
        
include_once("../Connect/conexion.php");
        
$conexion connect();
        
        
$cif_empresa $_REQUEST['cif_empresa'];
                /
Lo guardo para luego comprobar que modifique el adecuado
        $cif_antiguo
=$cif_empresa;
        
$sql "Select * from empresa where cif_empresa = '$cif_empresa'";
        
$res mysql_query($sql,$conexion);
        
$array mysql_fetch_array($res);
            
$nombre $array['nombre_empresa'];
                
//Lo guardo para luego comprobar que no es mi propio nombre de empresa
        
$nombre_antiguo $nombre;
        
$direccion $array['direccion'];
        
$cp $array['cp'];
        
$tel $array['tel'];
        
$poblacion $array['poblacion'];
        
$localidad $array['localidad'];        

        if(isset(
$_REQUEST["Guardar"])){
        
        
$cif_empresa $_REQUEST['cif_empresa'];
        
$nombre $_REQUEST['nombre'];
        
$direccion $_REQUEST['direccion'];
        
$cp $_REQUEST['cp'];
        
$tel $_REQUEST['tel'];
        
$poblacion $_REQUEST['poblacion'];
        
$localidad $_REQUEST['localidad'];    
    
        
$sql "Select * from empresa where nombre_empresa = '$nombre' And nombre_empresa<>'$nombre_antiguo'";
        
$res mysql_query($sql,$conexion);
        
$row mysql_num_rows($res);
        if(
$row){
            echo 
'Ya existe una empresa con ese nombre, introduzca otra empresa';
        }else{
        
        
$sql "Update empresa Set cif_empresa='$cif_empresa',nombre_empresa='$nombre',direccion='$direccion',cp='$cp',tel='$tel,'poblacion='$poblacion',localidad='$localidad' where cif_empresa='$cif_antiguo'";
        
$res mysql_query($sql,$conexion)or die("No se ha realizado la actualización");
        
$num mysql_num_rows($res);
        if(
$num==-1){
            echo 
'ERROR';
            }else{
                echo 
'<div align=center>La modificacion de la empresa fue satisfactorio</div>';
            }
        }
    }else{
?>    
    <form name="form" method="post" action="" id="form">
  <table width="450" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
      <td width="178"><strong>Cif empresa*</strong></td>
      <td width="272"><input name="cif_empresa" type="text" id="cif_empresa" size="30" value="<?=$cif_empresa?>"></td>
    </tr>
    <tr>
      <td width="178"><strong>Nombre empresa*</strong></td>
      <td width="272"><input name="nombre" type="text" id="nombre" size="30" value="<?=$nombre?>"></td>
    </tr>
    <tr>
      <td><strong>Dirección*</strong></td>
      <td><input name="direccion" type="text" id="direccion" size="30" value="<?=$direccion?>"></td>
    </tr>
    <tr>
      <td><strong>Teléfono*</strong></td>
      <td><input name="tel" type="text" id="tel" size="30" value="<?=$tel?>"></td>
    </tr>
    <tr>
      <td><strong>Código postal</strong></td>
      <td><input name="cp" type="text" id="cp" size="30" value="<?=$cp?>"></td>
    </tr>
    <tr>
      <td><strong>Población*</strong></td>
      <td><input name="poblacion" type="text" id="poblacion" size="30" value="<?=$poblacion?>"></td>
    </tr>
    <tr>
      <td><strong>Localidad*</strong></td>
      <td><input name="localidad" type="text" id="localidad" size="30" value="<?=$localidad?>"></td>
    </tr> 
    </table>
    <table width="450" border="0" align="center" cellpadding="2" cellspacing="2">
     <tr>
      <td align="center"><input type="submit" name="Guardar" value="Guardar" class="botton"></td>
    </tr>
    </table>
</form>
<?
}
?>
Les agradecería mucho que me pudiesen ayudar!!

Saludos.