Hello. There was such a problem.
$connection = new mysqli("localhost", "root", "root", "main"); mysqli_set_charset($connection, "utf8"); if ($result = mysqli_query($connection, "SELECT DISTINCT manufacturer FROM oc_1auto order by 1;")) { while($row = $result->fetch_array(MYSQL_ASSOC)) { $myArray[] = $row; } echo json_encode($myArray); } $result->close(); This code performs well, the data is displayed on the client side.
I want to include the file to connect to the database.
header('Content-Type: application/json'); include_once('./db_mysqli.php'); if ($result = mysqli_query($connection, "SELECT DISTINCT manufacturer FROM oc_1auto order by 1;")) { while($row = $result->fetch_array(MYSQL_ASSOC)) { $myArray[] = $row; } echo json_encode($myArray); } $result->close(); And nothing happens. Data does not come in json format.
Tell me where to look?
json_encode, thenjson_last_error()will help you to find out what is wrong inside and why it does not turn it. - alexoander