title: Unknown column 'posts.id' in 'field list'
body: <p>I am trying to fix an error on my PHP code. Could you please help me? </p>
  
  <p>This is the code:</p>
  
  <pre><code>function get_posts($id = null , $cat_id = null ) {
      $posts = array();
      $query = "SELECT `posts`.`id` AS `post_id`, `categories_id`.`id` AS `category_id`,
                       `title`, `contents`, `date_posted`, categories`.`name` 
                FROM `posts`
                INNER JOIN `categories` ON `categories`.`id` = `posts`.`cat_id`
                ORDER BY `posts`.`id` DESC";
  
      $query = mysql_query($query);
  
      while ( $row = mysql_fetch_assoc($query)) {
          $posts[] = $row;
      }
      echo mysql_error();
      return $posts;
  }
  </code></pre>
  
  <p>and I get: </p>
  
  <p>Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\blog\resources\func\blog.php on line 89</p>
  
  <p>Unknown column 'posts.id' in 'field list' </p>