Ver Mensaje Individual
  #27 (permalink)  
Antiguo 25/04/2008, 09:04
armen87
 
Fecha de Ingreso: abril-2008
Mensajes: 157
Antigüedad: 16 años
Puntos: 0
Re: borrado de datos

Lo he probado pero me da el siguiente error.


Cita:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\projectefinal\esbo_treballadors2.p hp on line 41
Error al fer el select

Código PHP:
<?php
$conexio
=mysql_connect("localhost","root","");
mysql_select_db("parc_atraccions",$conexio);  

    
$baixa=$_POST['esborra'];
    
$DNI=$_POST['DNI'];
    
$Nom=$_POST['Nom'];
    
$Cognom=$_POST['Cognom'];
    
$ver=$_POST['verificar'];

if (isset(
$_POST["esborra"])){ 
    
$resultat=mysql_query("DELETE  from treballadors WHERE DNI=$DNI",$conexio); 
    
$files=mysql_affected_rows($conexio);


if (
mysql_errno($conexio)==0){
    echo 
"<center><h2> FILES ELIMINADES: $files</h2></center>"
    echo 
"<br>";

}


    else 
    {
        
$numeroerror=mysql_errno($conexio);
        
$descripcioerror=mysql_error ($conexio); 
    
        echo 
"num_derror $numeroerror";
        echo 
"<br>";
        echo 
"descripcio $descripcioerror";
    }
    
}
//if($_POST["submit"]=="verificar"){ 
if (isset($_POST["verificar"])){
    
$resultat=mysql_query("SELECT Nom,Cognoms from treballadors WHERE DNI='$DNI'",$conexio);
    
$numero=mysql_num_rows($resultat);

        
        
        if (
mysql_errno($conexio)!=0){
    
        echo 
"<center><h2> Error al fer el select</h2></center>";       
        exit();
                                        }



if(
mysql_query($sql)){                                           
    echo 
"<center><h2> No existeix cap treballador amb aquest DNI </h2></center>";  
    exit();  
                    }  
                  

else     {   

        
$fila=mysql_num_rows($resultat);  
        echo
" Nom del treballador:".$_POST['Nom'];   
        echo 
"Cognom: ".$_POST['Cognom'];
        
//echo" Nom del treballador: '".$_POST['Nom']."'";  
        //echo "Cognom:'".$_POST['Cognom']."'";  
        
}  
          
}
exit();  

mysql_close();  

?>