I have this code:
$json = array();
$hoy = date("Y-m-d");
$consulta = "SELECT e.*,s.sal_nombre, concat(eve_titulo, ' - ',sal_nombre) as title FROM evento e, sala s where s.sal_id=e.sal_id ORDER BY id";
// conexión bbdd
try {
$bdd = new PDO('mysql:host=localhost;dbname=prueba2', 'root', '');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
//ejecutamos consulta
$resultado = $bdd->query($consulta) or die(print_r($bdd->errorInfo()));
// enviamos el resultado codificado en json a la página que lo llama
echo json_encode($resultado->fetchAll(PDO::FETCH_ASSOC));
$result = $resultado->rowCount();
print_r($result);
when printing result, it prints 4 that is the correct result but the json_encode returns nothing and if i do print_r($resultado->fetchAll());
it returns an empty array