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.
' . stripslashes($content) . '
';` – Prasenjit Kumar Nag Jun 03 '12 at 20:11'` get escaped in the file? If not, `$content` does not contain what you claim it does. `fwrite()` does not add slashes.
– CodeCaster Jun 03 '12 at 20:13