Popular array in online server

0

I'm a beginner in programming and I'm developing an android application that uses PHP and makes requests with Mysql. Initially I tested all the features on the local server to then migrate it to an online server, in this case, Hostinger.

One of my PHP files returns the value of an array correctly on the local server, however, when using the same PHP file on the online server with the same database, the array only responds as TRUE when I run echo .

I tried doing the echo of each line and it works perfectly, just not being able to associate the values with the keys.

$resultado = array();
$ordenado = mysqli_query($connect, $ordenarExercicio);  

while ($pacientes = $ordenado->fetch_assoc()){  
    echo $pacientes['grupo'];              //imprime OK
    echo $pacientes['nome_exercicio'];     //imprime OK
    echo $pacientes['utilizar_exercicio']; //imprime OK

    $resultado[] = array("grupo" => $pacientes['grupo'],    
                         "nome" => $pacientes['nome_exercicio'],
                         "habilitar" => $pacientes['utilizar_exercicio']
                        ); 

}

echo json_encode($resultado);  //imprime TRUE
    
asked by anonymous 06.02.2018 / 06:05

2 answers

0

Look, I do not quite understand ARRAYs in PHP, but from what I understand by the $ result variable, you do not need to have brackets before entering the value, since it will already make it an ARRAY.

$resultado = array("grupo" => $pacientes['grupo'],    
                     "nome" => $pacientes['nome_exercicio'],
                     "habilitar" => $pacientes['utilizar_exercicio']
               );
    
06.02.2018 / 10:52
0

Try to use the print_r ($ results) function to see the result of the array being sent.

And try to get the [] variables out of the $ result [] result.

    
06.02.2018 / 12:19