0

So the implementation is as follows , I include the database , which I know that it works , cause I had an or die (" can't connect to database ") which never prompts, so the root can connect to the db. I have a header for utf-8 decoding , but it did not work apparently. And when I echo json it returns nothing , just blank. Note: I use mariadb. Also the error reporting is set to On and I don't get any error.

<?php
header('Content-Type: 
charset=utf-8');
include('db_connect.php');

$stmt = $conn->prepare("SELECT col1, col2, col3 FROM table1");

$stmt ->execute();
$stmt -> bind_result($val1col1, $val2col2, $val3col3);

$values = array();

while($stmt ->fetch()){

   $temp = array();

   $temp['col1'] = $val1col1;
   $temp['col2'] =$val2col2;
   $temp['col3'] = $val3col3;

   array_push($values,$temp);
}

echo json_encode($values, false, 512, JSON_UNESCAPED_UNICODE);

?>

0 Answers0