title: I am getting mysql error check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 4
body: <p>I am getting my sql error "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 '?' at line 4</p>
  
  <p>SELECT cm.user_id, chat_message_content, u.firstname FROM chat_message cm JOIN user u ON cm.user_id = u.user_id WHERE cm.chat_id= ?"</p>
  
  <p>Model</p>
  
  <pre><code>function get_chat_messages($chat_id) {
          $query_str = "SELECT cm.user_id, chat_message_content, u.firstname
                        FROM chat_message cm
                        JOIN user u ON cm.user_id = u.user_id
                        WHERE cm.chat_id= ?";
          $results = $this-&gt;db-&gt;query($query_str, $chat_id);
          return $results;
      }
  </code></pre>