Jump to content

' gets changed to ' in fwrite script? how do i stop that


MadnessRed

Recommended Posts

i have an fwite script which writes to a txt file which i am php including.

 

If I write this to the file

 

<?php include('../base/newbox.php'); ?>

 

it gets written as

 

<?php include(\'../base/newbox.php\'); ?>

 

any ideas how to stop it writing the '/'s?

Link to comment
Share on other sites

yes sorry, there are 2 slashes no both sides, its just the forum does funny things to back slashes [ code ]

 

here is my code

 

$flsh = '../data/profile/flash.txt';

$flash=$_GET["flash"];

$handlefl = fopen($flsh, 'w');
fwrite($handlefl, $flash);

 

and

 

<?php include('data/profile/flash.txt'); ?>

 

whereabouts do i put the strip slashes?

 

Link to comment
Share on other sites

sorry i wasn't clear, i have an fwrite script that lets the user wrote a bit of code to a text file

 

I think am including the text file in the main document in a sepperate box

 

I want the user to be able to add

 

<?php include('../base/newbox.php'); ?>

 

to the text file which will give them a second box so for example flash.txt may say

 

 

<u>Information 1</u><br>
I like chips

<?php include('../base/newbox.php'); ?>

<u>Information 2</u><br>
I don't like bread

 

however if I add hte php include script into flash.txt its changes ' to /' then says it wasn't expecting a / and erors.

Link to comment
Share on other sites

Ok so your actually writing the code to a text file.. exactly as I see it now, or are you writing the text above/below AND the contents of newbox.php?

 

<u>Information 1</u><br>
I like chips

<?php include('../base/newbox.php'); ?>

<u>Information 2</u><br>
I don't like bread

 

Or are you writing...

 

<u>Information 1</u><br>
I like chips

(the output of the php part)

<u>Information 2</u><br>
I don't like bread

 

The reason this is happening is because magic_quotes_gpc is enabled on your server (like most servers). This setting automatically adds the slashes. So you need to strip them. If you are writing the actual php code to a text file, then whatever variable that text is stored in.. use this:

 

$mytext = "<u>Information 1</u><br>
I like chips

<?php include('../base/newbox.php'); ?>

<u>Information 2</u><br>
I don't like bread";

// This will output

// <u>Information 1</u><br>
// I like chips

// <?php include('../base/newbox.php'); ?>

// <u>Information 2</u><br>
// I don't like bread

stripslashes($mytext);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.