title: mysqli bind_param fails but why?
body: <p>The following error triggers a mysql error, this is due to query not binding the parameter to the statement. I do not understand why this is happening.</p>
  
  <p>This is the error returned by the else clause:</p>
  
  <pre><code>ERROR -&gt; 1064 : You have an error in your SQL syntax; check the manual 
  that corresponds to your MySQL server version for the right syntax to
  use near '? ORDER BY dateCreated DESC' at line 4`
  </code></pre>
  
  <p>Here is the code in question:</p>
  
  <pre><code>$userId = 1;
  if ($stmt = $link-&gt;query("
      SELECT o.id, dateCreated, firstValue
      FROM user_orders o 
      LEFT JOIN order_delivery d ON o.id = d.id 
      WHERE o.userId = ? 
      ORDER BY dateCreated DESC
  "))
  {
      $stmt-&gt;bind_param("i", $userId);
      $stmt-&gt;execute();
      $stmt-&gt;close();
  }
  else
  {
      $pageContent = '
          &lt;p&gt;ERROR -&gt; '.$link-&gt;errno.' : '.$link-&gt;error.'&lt;/p&gt;
      ';
  
  }
  </code></pre>
  
  <p>Could someone possibly point our where i have gone wrong with this and why this mysql error is occuring.</p>
  
  <p>Thank you for taking the time to read through this!</p>