title: php mysql left join where clause error
body: <p>With the following tables</p>
  
  <p>posts</p>
  
  <ul>
  <li>id</li>
  <li>post_id</li>
  <li>user_id</li>
  </ul>
  
  <p>comments</p>
  
  <ul>
  <li>id</li>
  <li>post_id</li>
  <li>comment_id</li>
  <li>user_id</li>
  <li>deleted</li>
  </ul>
  
  <p>replies</p>
  
  <ul>
  <li>id</li>
  <li>post_id</li>
  <li>reply_id</li>
  <li>user_id</li>
  <li>deleted</li>
  </ul>
  
  <p>I am trying to get every comment and reply from each post.post_id and post.user_id='x' and the comment  or reply is not deleted(0)</p>
  
  <p>this is what i have tried</p>
  
  <pre><code>SELECT *
  FROM posts p
  LEFT JOIN comments c ON p.id=c.post_id
  LEFT JOIN replies r ON p.id=r.post_id
  WHERE p.user_id=$user_id
  &amp;&amp; c.deleted='0' &amp;&amp; r.deleted='0'
  </code></pre>
  
  <p>which does not work...</p>