Jump to content

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


MadnessRed

Recommended Posts

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?

 

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.

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.