Does not show JSON PHP object


I want to show the result of the query in a JSON but it gives me an empty result, I suspect it is by SCOPE DE PHH, but I have not been able to solve it.


$conectar = mysqli_connect($nombre_host, $nombre_usuario, $contrasena_usuario, $nombre_bd);

if ($conectar) {
$consulta ="SELECT * FROM casas";
if ($resultado=$conectar->query($consulta)) {
    while ($fila=$resultado->fetch_row()) {
        $datos_json = json_encode($datos);
    echo $datos_json;
asked by Javier 20.12.2018 в 03:13

0 answers