I'm trying to fetch the results of a query into a PHP array, the query is really simple and returns exactly 94 rows, the process runs perfectly until it hits a certain number of results, I discovered this by trial and error, I thought it was a data problem but it's actually a PHP problem, because if I run the query the array empties but if I put a LIMIT in the query the process runs ok, the magic number is 37 after that the array won't fetch more rows and displays nothing, this is what I'm doing:
PD. the problem seems to be with the Name field because if I use only the id field I can fetch the 94 rows without problem.
$query = "SELECT Name AS DisplayText, id AS Value FROM branches ORDER BY DisplayText ASC LIMIT 37;";
$conn = new mysqli($host, $username, $password, $database);
$res = $conn->query($query);
$rows= array();
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$array['DisplayText'] = $row['DisplayText'];
$array['Value'] = $row['Value'];
array_push($rows,$array);
}
print json_encode($rows);
this way works but I'm limited to 37 results because of the query limit, I need the 94 results, but if I remove the limit I get nothing
other way I tried with the same result:
$query = "SELECT Name AS DisplayText, id AS Value FROM branches ORDER BY DisplayText ASC LIMIT 37;";
$conn = new mysqli($host, $username, $password, $database);
$res = $conn->query($query);
$rows= array();//rows
while ($row= mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$rows[] = $row;
}
print json_encode($rows);