Gostaria de saber se alguém encontra algum erro em meu código pois estou à tentar criar um Json com o PHP porem ele só retorna NULL
.
Meu servidor Host utiliza PHP 5.6
<?PHP
$host = "...";
$usuario = "...";
$senha = "...";
$banco = "...";
$database = mysqli_connect($host,$usuario,$senha,$banco);
$result=mysqli_query("SELECT * FROM tbconsultas");
$i=0;
while($row=mysqli_fetch_array($result)) {
$response[$i]['url'] = $row['url'];
$response[$i]['title']= $row['title'];
$data['posts'][$i] = $response[$i];
$i=$i+1;
}
$json_string = json_encode($data);
$file = 'file.json';
file_put_contents($file, $json_string);
?>
error_reporting(E_ALL);
ai verifica se deu alguma mensagem e posta aqui pra ajudar.