目前正在尝试在Azure上进行Web服务。尽管经过调整,返回的数组总是空白的。将echo插入$ stmt
时,响应码为#3<?php
// Include confi.php
include_once('confi.php');
$asset_id = $_GET['asset_id'];
if(!empty($asset_id)){
$qur = sqlsrv_query("SELECT asset_name,operating_system ,serial_no ,asset_status FROM [dbo].[assets] WHERE [asset_id]='".$asset_id."'");
$stmt = sqlsrv_query( $conn, $qur);
$result =array();
while($row = sqlsrv_fetch_array($stmt)){
//extract($row);
$result[] = array('asset_name' => $row["asset_name"], 'operating_system' => $row["operating_system"], 'serial_no' => $row["serial_no"], 'asset_status' => $row["asset_status"]);
}
$json = "info" => $result;
}else{
$json = array("msg" => "Asset not found");
}
@sqlsrv_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
结果如下:
[[]]