0
I am developing a PHP API with Slim Framework, but when I require the class general it should make a query in the database and return me the data of this table in JSON.
This is the connection class with the database
<?php
$host = "localhost";
$usuario = "root";
$senha = "";
$bd_nome = "liceuapp";
$mysqli = new mysqli($host, $usuario, $senha, $bd_nome);
This is the class that does the query in the database and should return me the JSON of this table
<?php
$app->get('/comunicados/geral', function() {
require_once('dbconnect.php');
$query = "select * from geral";
$result = $mysqli->query($query);
while($row = $result->fetch_assoc()) {
$data[] = $row;
}
if (isset($data)) {
echo json_encode($data);
}
});
However, when I call the URL api/communications/general the screen turns white, does not display the JSON of the requested table.
Help me out, please!
"The screen turns white" could mean that there was an error. Have you checked the logs? Do you really have records in this table (will you)? PHP is configured to display errors?
– LipESprY