Warning: sqlsrv_fetch_array () expects parameter 1 to be resource, boolean given in

1

I have a form that enters people, but I have problems validating using sqlsrv_num_rows() the error is as follows:

  

Warning: sqlsrv_num_rows () expects parameter 1 to be resource, boolean given in

<?php
include "conexion.php";
function ingresar(){

$con=conectar();

$nom=$_POST['nombre'];
$rut=$_POST['rut'];
$tel=$_POST['telefono'];
$dir=$_POST['direccion'];

    $sql="select RutAux From cwtauxi where RutAux=$rut";
    $stmt=sqlsrv_query($con,$sql);

    error-> if(sqlsrv_num_rows($stmt)>0){
        ?>
                  <div class="alert-false" role="alert">El Registro ya existe</div><?php
                        sqlsrv_close($con); 

    }else{

          $sql2="insert into cwtauxi (NomAux,RutAux,DirAux,FonAux1)values ('$nom','$rut','$dir','$tel')";
          $stmt2= sqlsrv_query($con, $sql2);
          if($stmt2){

              ?><div class="alert-true" role="alert">Datos ingresados</div><?php
                            sqlsrv_close($con);

          }else{        
                  ?>
                  <div class="alert-false" role="alert">ERROR: <?php  print_r( sqlsrv_errors())?> </div><?php
                                sqlsrv_close($con);

          }         
    }

}
?>
    
asked by Johann Sebastian Painevil Len 09.07.2018 в 23:49
source

0 answers