How to display data from a SQL Server query using PHP?

0

I'm trying to display data from a table in my SQL Server database using PHP, but I'm not getting it. The code does not error but also returns nothing.

The code is this here:

<?php
$serverName = "MIRCIA-PC\PRIMAVERA";
$resultadoectionInfo = array( "Database"=>"PRICVE", "UID"=>"sa", "PWD"=>"INFODMIDMI99" );
$resultado = sqlsrv_connect( $serverName, $resultadoectionInfo);
if( $resultado === false ) {
  die( print_r( sqlsrv_errors(), true));
}

$query=sqlsrv_query($resultado,"SELECT SELECT Artigo, Descricao, STKMaximo, STKMinimo, STKActual FROM Artigo");

if($query){
  while($row=sqlsrv_fetch_array($query)){
    $flag[]=$row;
  }
  print (json_encode($flag));
}
sqlsrv_close($resultado);
?>
    
asked by anonymous 16.06.2018 / 18:55

1 answer

0

When you do the Database Select you have the bad structure because you are repeating the select

How does yours appear:

  

$ query = sqlsrv_query ($ result, " SELECT SELECT Article, Description, STKMaximo, STKMinimo, STKActual FROM Article");

How should it be:

  

$ query = sqlsrv_query ($ result, " SELECT Article, Description, STKMaximo, STKMinimo, STKActual FROM Article");

    
18.06.2018 / 10:53