title: Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, bool given
body: <p>I'm trying to print records but my code returns error:</p>
  <blockquote>
  <p>Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, bool given.
  Here comes code:</p>
  </blockquote>
  <pre><code>$sql2 = &quot;SELECT DISTINCT
  'r.Report_Id,
  r.Report_Name,
  r.Person_Id, 
  r.Person_Name,
  r.Report_Type,
  r.Report_Importance,
  rkr.KPI_Id,
  kpis.KPI_name
  
  FROM Reports r 
  
  left outer join Frequencies f  on r.RefreshFrequency_Id = f.RefreshFrequency_Id 
  left outer join Instructions i on r.Instruction_Id = i.Instruction_Id
  left outer join ReportFamily rf on r.ReportFamily_Id = rf.ReportFamily_Id
  
  left outer join ReportsMpCpRel rmr on r.Report_Id = rmr.Report_Id
  left outer join MpCp mpc on rmr.MpCp_Id = mpc.MpCp_Id
  left outer join RNA rn on mpc.Existst_RNA_Id = rn.Existst_RNA_Id
  
  left outer join ReportsKpiRel RKR on r.Report_Id = RKR.Report_Id
  left outer join KPI kpis on RKR.KPI_Id = kpis.KPI_Id
  
  WHERE r.Report_Id' = '&quot;.$selected.&quot;'&quot;;
  
  $stmt2 = sqlsrv_query($conn, $sql2);
  
        while( $row2 = sqlsrv_fetch_array( $stmt2, SQLSRV_FETCH_NUMERIC) ) 
              {
  
               echo '&lt;br&gt;'.$row2[0];
               echo '&lt;br&gt;'.$row2[1];
               echo '&lt;br&gt;'.$row2[2];
              }
  </code></pre>