Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:01:55+00:00 2026-06-05T00:01:55+00:00

In my code I am having PHP write a variable into a text file.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:01:57+00:00Added an answer on June 5, 2026 at 12:01 am

    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:

    <?php
    if (get_magic_quotes_gpc()) {
        function stripslashes_gpc(&$value)
        {
            $value = stripslashes($value);
        }
        array_walk_recursive($_GET, 'stripslashes_gpc');
        array_walk_recursive($_POST, 'stripslashes_gpc');
        array_walk_recursive($_COOKIE, 'stripslashes_gpc');
        array_walk_recursive($_REQUEST, 'stripslashes_gpc');
    }
    ?>
    

    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:

    if (get_magic_quotes_gpc()) {
      $content = stripslashes($_POST['bcontent']);
    }else{
      $content = $_POST['bcontent'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a php file which executes some code to generate a html
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);
I'm having a problem with these lines of code: <a class=button href=javascript:unhide('<?php $a; ?>')>Expand
I am having a link <a id=test href=text.php>test</a> I have the following jquery code
I'm trying to translate a PHP class into JavaScript. The only thing I'm having
I have written this code having not used PHP for 2 years now to
I'm having issues getting a php form to write to a file hosted with
I'm having difficultly figuring out how to write this block of code... function myFunction(x,y,z)
Hi im having problems with my PHP code for sending an email via a
I'm having a problem with some code that used to work in PHP 4.X

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.