I'm attempting to return all the rows of my MSSQL database table and spit them out in a JSON_ENCODE.
When I use this and echo the $json I get a blank page. When I do a var_dump on that var I get a bool, false.
$sth = $db->prepare("SELECT * FROM dbo.Devices");
$sth->execute();
$array = $sth->fetchAll( PDO::FETCH_ASSOC );
$json = json_encode($array);
However, if I was to place the same fetchAll into a result var and print it, it works fine!
Working using print function.
$result = $sth->FetchAll();
print_r($result);
I've read of others having similar issues and that it was a UTF8 encoding issue so I attempted to do a utf8_encode on the $array before a json_encode but with the same result of a blank page. Can anyone explain this?