For an phone app, I created an API. Content is always up to date as it's all coming form this API. I'm changing it now to include more things, and in my MySQL data model one of my fields is a LONGTEXT field to achieve this, which I want to output in my JSON file.
When outputting the MySQL table, everything appears in the JSON file, except the longtext field, this remains null in the output.
<?php
include "specialchar.php";
$sqlTour = "SELECT * FROM tour where id = '" . $id . "'";
$sqlSteps = "SELECT * FROM tourSteps where id = '" . $id . "'";
$resultTour = mysqli_query($con, $sqlTour);
$resultSteps = mysqli_query($con, $sqlSteps);
$json = array();
$json2 = array();
$json = (mysqli_fetch_array($resultTour));
$json = array_map("utf8_encode", $json);
while ($row = mysqli_fetch_array($resultSteps)) {
//create JSON output;
$json2[] = array_map("utf8_encode", $row);
}
$json['steps'] = $json2;
$response['audiotour'] = $json;
$response = json_encode($response);
echo(Utf8_ansi($response));
$con->close();
?>
Anyone an idea?
I have tried using JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_HEX_QUOT in the json_encode function.
There was a mismatch in my variable names. Problem is solved now without changing this code.