My code looks like this:
$hostname = 'myhost.com';
$database = 'heading';
$username = 'me';
$password = 'pw';
$dbh = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * from mytable";
$result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
//var_dump($result); //This works and dumps the array with the right data
header('Content-type: application/json');
echo json_encode($result);
This echo
s nothing back though. No errors, just nothing. If I try echo($result)
this echos "Array".
What's happening here?