title: Trying to get mysqli_fetch_assoc working with bind_param
body: <p>This works, it returns my array in the form:</p>
  
  <pre><code>{"results":[{"cat_id":"8",
  "cat_name":"dental hygienist"},
  {"cat_id":"5","cat_name":"stocktaker"},
  {"cat_id":"9","cat_name":"builder"}]}
  </code></pre>
  
  <p>My php code is :</p>
  
  <pre><code>$query2 = "SELECT DISTINCT cat_id,cat_name FROM review WHERE public_or_private = 2";
  $result2 = mysqli_query($con,$query2);
  $rows = array();
  while($row = mysqli_fetch_assoc($result2)) {
      $rows['results'][] = $row;
  }  
  echo json_encode($rows);
  </code></pre>
  
  <p>But how can I get similar to work with parameterised queries? </p>
  
  <p><code>mysqli_query()</code>, <code>mysqli_store_result()</code> or <code>mysqli_use_result()</code>... I've tried several things like this but I keep getting <code>null</code>.</p>
  
  <p>My php code:</p>
  
  <pre><code>$query3 = "SELECT DISTINCT cat_id,cat_name FROM review WHERE user_id = ? AND public_or_private = 0";
  $stmt3 = $con-&gt;prepare($query3) or die(mysqli_error($con));
  $stmt3-&gt;bind_param('i', $user_id) or die ("MySQLi-stmt binding failed ".$stmt3-&gt;error);
  $stmt3-&gt;execute() or die ("MySQLi-stmt execute failed ".$stmt3-&gt;error);
  $result3 = $stmt3-&gt;get_result();
  $rows = array();
  while ($row = mysqli_fetch_assoc($result3)) {
      $rows['results'][] = $row;
  } 
  echo json_encode($rows);
  </code></pre>