我正在构建一个PHP页面以从Azure SQL数据库读取数据。这似乎是连接和查询的作品,但我无法获得任何返回的数据显示。
我在网页上得到的输出是
Connection established.
Statement executed.
There are rows.
$connectionInfo = array( "Database"=>"sitrap", "UID"=>"xxxxxx@xxxxxx", "PWD"=>"xxxxxx");
$serverName = "tcp:xxxxxx.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.
";
}else{
echo "Connection could not be established.
";
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT time, callsign FROM reports";
$stmt = sqlsrv_query($conn, $sql);
if ( $stmt )
{
echo "Statement executed.
\n";
}
else
{
echo "Error in statement execution.\n";
die( print_r( sqlsrv_errors(), true));
}
if ($stmt) {
$rows = sqlsrv_has_rows( $stmt );
if ($rows === true)
echo "There are rows.
";
else
echo "There are no rows.
";
}
while ($row = sqlsrv_fetch_array($stmt))
{
?>
<?php echo $row["time"];?><?php echo $row["callsign"];?>}
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>