title: PHP mysql_real_escape_string() -> stripslashes() leaving multiple slashes
body: <p>I'm having issues escaping/stripping strings with PHP/MySQL - there always seems to be redundant slashes.</p>
  
  <hr />
  
  <p>Let's take the following string as an example:</p>
  
  <pre><code>&lt;span style="text-decoration:underline;"&gt;underline&lt;/span&gt;
  </code></pre>
  
  <p><br />
  When adding a string to the database, I'm escaping it with <code>mysql_real_escape_string()</code> and the following gets stored in the database (<strong>EDIT</strong>: checked this by querying the database directly with mysql app):</p>
  
  <pre><code>&lt;span style=\\\"text-decoration:underline;\\\"&gt;underline&lt;/span&gt;
  </code></pre>
  
  <p><br />
  When reading back out of the database, I'm passing the string through <code>stripslashes()</code> and the following is returned:</p>
  
  <pre><code>&lt;span style=\"text-decoration:underline;\"&gt;underline&lt;/span&gt;
  </code></pre>
  
  <p><br />
  Since the quotes are still escaped, it breaks the html and the text is not underlined.</p>
  
  <hr />
  
  <ol>
  <li>Why is <code>mysql_real_escape_string()</code> adding three slashes, and <code>stripslashes()</code> removing two slashes? I would expect them both to add/remove one slash.</li>
  <li>How can I prevent this from happening?</li>
  <li>Am I approaching this the correct way?</li>
  </ol>