title: How do I retrieve an associative array with prepared statements?
body: <p>In the php documentation on fetching associative arrays (<a href="http://php.net/manual/en/mysqli-result.fetch-assoc.php" rel="nofollow">http://php.net/manual/en/mysqli-result.fetch-assoc.php</a>) it doesn't give any examples that use prepared statements. I tried reinterpreting the code given there to use the prepared statements stuff I've done in the past which does work. But this code just errors. Is it possible then to use prepared statements for this? If so, how?</p>
  
  <pre><code>    &lt;?php
      $mysqli = new mysqli('website','username','pw','db');
  
      /* check connection */
      if (mysqli_connect_errno()) {
          printf("Connect failed: %s\n", mysqli_connect_error());
          exit();
      }
  
      $startTime = 1389056400;
      $query = $mysqli-&gt;prepare("SELECT * FROM Table2 WHERE Start = ?");
      $query-&gt;bind_param('i', $startTime);
      $result = $mysqli-&gt;query($query);
  
      /* associative array */
      $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
      echo $row["Start"];
      echo $row["End"];
  
      /* free result set */
      $result-&gt;free();
  
      /* close connection */
      $mysqli-&gt;close();
      ?&gt;
  </code></pre>