title: $result->fetch_all(MYSQLI_ASSOC) returns nothing
body: <p>I'm trying to create a JSON callback. I got two files, json.html and json.php. Also, I've a database with like this:</p>
  
  <pre><code>Type: MySQL
  DB Name: user_table
  Table name: customers
  Fields: id, name, product, supplier
  </code></pre>
  
  <p>Codes of my json.html is:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="demo" style="font-size: 20px;"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  
  obj = { "table":"customers", "limit":10 };
  dbParam = JSON.stringify(obj);
  xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
          myObj = JSON.parse(this.responseText);
          for (x in myObj) {
              txt += myObj[x] + "&lt;br&gt;";
          }
          document.getElementById("demo").innerHTML = txt;
      }
  };
  xmlhttp.open("POST", "json.php", true);
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.send("x=" + dbParam);
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is the codes of json.php:</p>
  
  <pre><code>&lt;?php
  
  $servername = "localhost";
  $username = "user";
  $password = "pass";
  $dbname = "db";
  
  header("Content-Type: application/json; charset=UTF-8");
  $obj = json_decode($_POST["x"], false);
  
  $conn = new mysqli($servername, $username, $password, $dbname);
  $result = $conn-&gt;query("SELECT name FROM ".$obj-&gt;$table." LIMIT ".$obj-&gt;$limit);
  $outp = array();
  $outp = $result-&gt;fetch_all(MYSQLI_ASSOC);
  
  echo json_encode($outp);
  
  ?&gt;
  </code></pre>
  
  <p>Here is the error log reports:</p>
  
  <p><strong>PHP Notice:</strong>  Undefined variable: table in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Fatal error:</strong>  Cannot access empty property in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Notice:</strong>  Undefined index: x in /home/user/public_html/json/json.php on line 4
  <strong>PHP Notice:</strong>  Undefined variable: table in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Notice:</strong>  Trying to get property of non-object in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Notice:</strong>  Undefined variable: limit in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Notice:</strong>  Trying to get property of non-object in /home/user/public_html/json/json.php on line 7</p>
  
  <p><strong>PHP Fatal error:</strong>  Call to a member function fetch_all() on a non-object in /home/user/public_html/json/json.php on line 9</p>
  
  <p>How can I make it work?</p>