I want to get all the rows from a table and store them in an array. Whenever fetch_all is used, the page crashes without any error messages. All other fetch options (fetch_assoc, fetch_array, etc..) work.
Code snippet that calls getcourses.php:
 $.ajax({
      url: 'getcourses.php',
      success: function(data){
           //do stuff
      }
 });
getcourses.php:
<?php
  require('includes/db.php');
  $query = "SELECT * FROM course";
  if($result = $mysqli->query($query)){
    echo json_encode($result->fetch_all(MYSQLI_ASSOC));
    $result->close();
  }
  $mysqli->close();
?>
db.php:
$host = 'localhost';
$user = 'user';
$pass = 'pass';
$db = 'db'; 
$mysqli = new mysqli($host,$user,$pass,$db) or die($mysqli->error);
PHP version is 5.4.16 (CLI). The operating system is GNU. mysqlnd is installed.
This exact code does work on my ubuntu server with PHP version 7.2.24.
I am aware I can make a loop and use $result->fetch_assoc. However, getting this to work would be much better.
