title: SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax
body: <p>Query FailedYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'comment_status = 'Approved' ORDER BY comment_id DESC' at line 1</p>
  
  <p>This is my code</p>
  
  <pre><code>&lt;?php
      $query = "SELECT * FROM comments WHERE comment_post_id = {$the_post_id}";
      $query .= "AND comment_status = 'Approved' ";
      $query .= "ORDER BY comment_id DESC";
      $select_comment_query = mysqli_query($connection, $query);
      if(!$select_comment_query){
          die('Query Failed'. mysqli_error($connection));
      }
      while ($row = mysqli_fetch_array($select_comment_query)) {
          $comment_date = $row['comment_date'];
          $comment_content = $row['comment_content'];
          $comment_author = $row['comment_author'];
  ?&gt;
  
  &lt;!-- Comments --&gt;
  &lt;div class="media"&gt;
      &lt;a class="pull-left" href="#"&gt;
          &lt;img class="media-object" src="http://placehold.it/64x64" alt=""&gt;
      &lt;/a&gt;
      &lt;div class="media-body"&gt;
          &lt;h4 class="media-heading"&gt;&lt;?php echo $comment_author; ?&gt;
              &lt;small&gt;&lt;?php echo $comment_date; ?&gt;&lt;/small&gt;
          &lt;/h4&gt;
          &lt;?php echo $comment_content; ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>If I disable the following codes, it works</p>
  
  <pre><code>    $query .= "AND comment_status = 'Approved' ";
      $query .= "ORDER BY comment_id DESC";
  </code></pre>
  
  <p>Thank you</p>