<?php
$route = intval($_GET['route']);
$link = mssql_connect('localhost\SQLEXPRESS','***','*********') or die("Couldn't connect to SQL Server on $myServer. Error: " . mssql_get_last_message());
mssql_select_db('PDQ',$link) or die('Cannot select the DB');
$query = "SELECT * FROM CUSTOMER WHERE CUS_ROUTE = $route";
$result = mssql_query($query,$link) or die('Errant query: '.$query);
$rows = array();
while($row = mssql_fetch_assoc($result)) {
$rows[] = $row;
}
echo json_encode($rows);
@mssql_close($link);
?>
My Result is:
[
{
CUS_DLT: 2,
CUS_COMPANY: 1,
CUS_CUSTOMSTRING2: "TIMES MARKET # 9"
},
{
CUS_DLT: 2,
CUS_COMPANY: 1
CUS_CUSTOMSTRING2: "TIMES MARKET # 8"
}
]
However this is not a valid json_encode because the column names are not wrapped in ". Does anyone know why or how to fix this?