removing quotes in PHP a bit complicated maybe
<p>I have this peace of code which brings string searches for img tags in it and adds class to img tags. Then I save everything back and send it to database.</p>

<pre><code>$doc = new DOMDocument();
$doc-&gt;loadHTML($article_header);

$imgs = $doc-&gt;getElementsByTagName('img');
foreach ($imgs as $img) {

    if($img-&gt;getAttribute('class')){
    } 
    else {
        $img-&gt;setAttribute('class', 'someclass');
        $article_header = $doc-&gt;saveXml();
    }
}
</code></pre>

<p>Problem is that the result becomes like this</p>

<pre><code>&lt;?xml version="1.0" standalone="yes"?&gt; &lt;!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd"&gt; &lt;html&gt;&lt;body&gt;&lt;p&gt;&lt;img
src="&amp;quot;some_url/some_pic.jpg&amp;quot;"
alt="&amp;quot;&amp;quot;" width="&amp;quot;528&amp;quot;"
height="&amp;quot;722.0512820512821&amp;quot;"
class="someclass"/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>So how can I get rid of this quot; things ???
I've read that it's phps magic quotes and tryied stripslashes on them like this</p>

<pre><code>$article_header = stripslashes($doc-&gt;saveXml());
</code></pre>

<p>But this doesn't help.</p>

<p><strong>UPDATE</strong></p>

<pre><code>&lt;img width="\"528\"" height="\"722.0512820512821\"" alt="\"\"" src="%5C%22sources/public/users/103/articles/2011-06-11/3/img/1170x1600.gif%5C%22"&gt;
</code></pre>

<p>This kind of weird code I get from TinyMCE editor. Before I do DOM things to it. As I see it's already damaged. I wonder how :(</p>

<p><strong>UPDATE 2</strong></p>

<p>Problem found This was because of this</p>

<pre><code>$article_header=mysql_real_escape_string($_POST['article_header']);
</code></pre>

<p>If I remove <strong>mysql_real_escape_string</strong> everything is ok. But New question if I do so, what should I use instead of it to add some security to my script?</p>

<p><strong>SOLVED</strong>
I removed mysql_real_escape_string and use them only when I'm passing data to mysql</p>
