Warning: sqlsrv_has_rows () expects parameter 1 to be resource, boolean given (using inner join)

0

I need help with this, I did not come across any surprises until I had to perform a inner join . It's the first time I use one with php. Maybe my syntax is incorrect.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<?php include "lib/metodosbd.php";?>
<title>Consultar Guias</title>
<meta name="viewport" content="width=device-width"/>
<link href="css/bootstrap.css" rel="stylesheet" >
<link rel="stylesheet" href="css/style.css">

</head>

<body>
<header>
<div class="div-header">
  <section class="main row">
      <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1">
        <img src="img/OXblanco.png" width="320" height="107" >
      </div>

      <div class="col-xs-11 col-sm-11 col-md-11 col-lg-11">
      </div>
   </section> 
  </div> 
</header>

<div class="container">
  <h2>Consultar guias</h2>

     <section class="main row" >
       <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
         <form  method="get" >
             <input name="folio" type="text"  id="folio" placeholder="Folio"             
/>
             <button type="submit" name="btn-guia" id="btn-guia">Consultar</button>
         </form>

         <?php
              if(isset($_GET['btn-guia'])){
                  consulta_guia();
              }

          ?>
       </div>


    </section>    
</div>  
 <script src="js/jquery.js"></script>
 <script src="js/bootstrap.min.js"></script>  
</body>
</html>

Here metodosbd.php

     <head>
    <link href="../css/bootstrap.css" rel="stylesheet" >
    <link rel="stylesheet" href="../css/style.css">

    </head>
    <?php
    include "conexion.php";

    function consulta_guia(){
        $con=conectar();

        $n_guia=$_GET['folio'];


    $stmtS="SELECT     iw_gmovi.Tipo, iw_gsaen.Folio, iw_gmovi.CodProd, iw_gmovi.CodBode, iw_gmovi.CantIngresada, iw_gmovi.CantDespachada, iw_gsaen.Estado FROM iw_gmovi INNER JOIN iw_gsaen ON     iw_gmovi.'Tipo' = iw_gsaen.'Tipo' AND iw_gmovi.NroInt = iw_gsaen.NroInt WHERE (iw_gmovi.Tipo IN ('s', 'e'))";

    $queryS=sqlsrv_query($con,$stmtS);

    if(sqlsrv_has_rows($queryS)){<-- aqui el error
    ?> 

    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 ">
    <table align="center" style="margin:auto auto auto auto;" class="table table-bordered table-responsive">
        <tr >
            <td>Estado</td>
            <td>N° Guia</td>
            <td>Bodega</td>
            <td>Codigo producto</td>
            <td>Descripcion producto</td>
            <td>Cantidad entrada</td>
            <td>Cantidad salia</td>
            <td>Diferencias</td>
        </tr>
    <?php



        $i=0;

        while($fila=sqlsrv_fetch_array($queryS)){

            $EST=$fila['iw_gmovi.Tipo'];
            $N_GUI=$fila['iw_gmovi.NroInt'];
            $BOD=$fila['iw_gmovi.CodBode'];
            $COD_PORD=$fila['iw_gmovi.CodProd'];
            $DES_PROD=$fila['iw_gmovi.DetProd'];
            $CANT_SAL=$fila['iw_gmovi.CantDespachada'];
            $CANT_ENT=$fila['iw_gmovi.CantIngresada'];
            $DIF=$CANT_ENT['iw_gmovi.CantIngresada'] - $CANT_SAL['iw_gmovi.CantDespachada'];
            $i++;

        ?>
        <tr align="center" valign="middle" >
        <td ><?php echo $EST; ?></td>
        <td><?php echo $BOD; ?></td>
        <td><?php echo $COD_PORD; ?></td>
        <td><?php echo $DES_PROD; ?></td>
        <td><?php echo $CANT_SAL; ?></td>
        <td><?php echo $DES_PROD; ?></td>
        <td><?php echo $DIF; ?></td>
        </tr>
        <?php
        }
        ?>
    </table>
        </div>
        <?php }else{
        ?><div class="alert-false" role="alert">ERROR: La guia no existe <br /> <?php  print_r( sqlsrv_errors())?> </div><?php
    }
    }

    ?>

It is worth mentioning that I tried the program executing a selec * from iw_gmovi and I managed to print the field iw_gmovi.Type only to know if my program worked besides these fields are varchar type.

    
asked by Johann Sebastian Painevil Len 24.07.2018 в 03:41
source

0 answers