Currently trying to do a web service at Azure. Despite tweaking around, the array returned is always blank. There is a response code #3 when I inserted echo to $stmt
<?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);
This is the result:
[[]]