title: how to escape single quote from ODBC query
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5713837/correct-way-to-escape-input-data-before-passing-to-odbc">Correct way to escape input data before passing to ODBC</a>  </p>
  </blockquote>
  
  
  
  <p>the error I am getting from querying a ODBC query is this:</p>
  
  <pre><code>(pos: 72 '...M = 'Owen O'^Donavon' AND...') - syntax error
  </code></pre>
  
  <p>and when I try to escape it:</p>
  
  <pre><code>(pos: 73 '... = 'Owen O\'^Donavon' AND...') - syntax error
  </code></pre>
  
  <p>the ^ means that is where it is breaking</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>NAM = '".$var."'
  </code></pre>
  
  <p>And also this:</p>
  
  <pre><code>NAM = '".mysql_escape_string($var)."'
  </code></pre>
  
  <p>then I got desperate</p>
  
  <pre><code>NAM = \"".$var."\"
  </code></pre>
  
  <p>Where $var is any name that contains a ' in it.</p>
  
  <p>if you need the whole query:</p>
  
  <pre><code>UPDATE TABLE SET COLUMN1 = 'ERR' WHERE COLUMN_NAM = '".mysql_escape_string($var)."' AND COLUMN7 = 0");
  </code></pre>
  
  <p>does anybody know how I can get the quote properly escaped?</p>