title: Searching MySQL for data that contains backslashes
body: <p>In a database, I have some text stored in a field call Description, the value of the string saved in my database is <code>Me\You "R'S'" %</code> and thats how it appears when querying the database command line.</p>
  
  <p>Now, on a web page i have a function which searches this field as such:</p>
  
  <blockquote>
    <p>WHERE Description LIKE '%$searchstring%'</p>
  </blockquote>
  
  <p>So when $searchstring has been cleaned, if i was searching for <code>Me\You</code>, the backslash gets escape and my query reads:</p>
  
  <blockquote>
    <p>WHERE Description LIKE '%Me\\You%'</p>
  </blockquote>
  
  <p>However it doesn't return anything.</p>
  
  <p>Strange part of this, is that when i search Me\\You or Me\\\You (So two or three backslashes, but no less or no more) it will return the result i expect with one backslash.</p>
  
  <p>When querying for the result command-line, it does not return a result for:</p>
  
  <blockquote>
    <p>WHERE Description LIKE '%Me\You%'</p>
  </blockquote>
  
  <p>or when i use two or three backslashes.</p>
  
  <p>However it will return the result if i use 4 - 7 backslashes, for example:</p>
  
  <blockquote>
    <p>WHERE Description LIKE '%Me\\\\\\\You%'</p>
  </blockquote>
  
  <p>will return the string which is <code>Me\You "R'S'" %</code></p>
  
  <p>Anyone have a reason to this happening? Thanks</p>