title: mysql error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
body: <p>I always get this error when executing the query:</p>
  
  <blockquote>
    <p>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 'read =1 WHERE user_id_sender = 1 AND user_id_receiver = 33 AND OR user_id_sender' at line 1</p>
  </blockquote>
  
  <p>This is my query: </p>
  
  <pre><code>mysql_query("UPDATE messages SET read =1 WHERE user_id_sender = $user_id AND user_id_receiver = $user_id_partner AND read = 0 OR user_id_sender = $user_id_partner AND user_id_receiver = $user_id  AND read = 0  ") or die (mysql_error());
  </code></pre>
  
  <p>the <code>table(messages)</code> has these columns:</p>
  
  <pre><code>message_id(INT)(AI)
  user_id_sender(INT)
  user_id_receiver(INT)
  message(TEXT)
  read(INT)
  </code></pre>
  
  <p>I really don't know why it does this, i have looked the web but I can't seem to find an answer for my exact problem. Maybe somebody could help me out.</p>