In my code I am having PHP write a variable into a text file.
$stringData = '<p class="blogcontent">' . $content . '</p>';
fwrite($fh, $stringData);
The variable $content
includes this <img src="bpictures/blue.jpg" width="200" />
But when the variable is written in to the text file this is written into it.
<img src=\"bpictures/blue.jpg\" width=\"200\" />
And it causes the image not to work when returned into html. I have tried using echo stripslashes($content);
but that doesn't work, Is there any way that I can write into the text file just the straight code that I have in the variable? I can't find an answer on Google.
How content is made.
<span class="addblog">Content (Include img tags from below):</span> <textarea cols="90" rows="50" name="bcontent"> </textarea> <br />
On submit.
$content = $_POST["bcontent"];
There is much more to the code but this is all that effects content for the most part.
The problem is that you have magic_quotes enabled.
If you can't disable them on the php.ini, you can use this function I found here on stackoverflow a while ago, to disable then at run time:
Found the original post related to this subject, here!
There are other solutions present there, but this was the one I've used.
EDITED
From the above link a simple solution to deal with the
$_POST
: