I've read for larger result sets I must use the MYSQL_USE_RESULT option when querying. This I do. However, the below PHP page is accessed via ajax and I receive 0 results once the known number of results reaches ~800. Before I reach this threshold, queries execute splendidly.
All queries work fine in phpmyAdmin.
What am I doing wrong?
<?php
$servername = "localhost";
$username = "user";
$password = "password";
$database = "mydb";
$mypassword = "expectedPassword";
$receivedPassword =$_POST["pwd"];
if ($receivedPassword != $mypassword) {
print "credential failure";
} else {
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
$myquery =$_POST["query"];
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
}
$res = $conn->query($myquery, MYSQLI_USE_RESULT);
$rows = array();
while ($r = mysqli_fetch_assoc($res)) {
$rows[] = $r;
}
$conn->close();
print(json_encode($rows));
}
?>