MadnessRed Posted May 23, 2008 Share Posted May 23, 2008 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 https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/ Share on other sites More sharing options...
gamefreak13 Posted May 23, 2008 Share Posted May 23, 2008 Is it only adding it on the right side? I think your looking for stripslashes();. Whatever variable is outputting that, try this.. stripslashes($outputtotxt); Link to comment https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/#findComment-547992 Share on other sites More sharing options...
MadnessRed Posted May 23, 2008 Author Share Posted May 23, 2008 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 https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/#findComment-547996 Share on other sites More sharing options...
gamefreak13 Posted May 23, 2008 Share Posted May 23, 2008 I thought you were writing the php include to a text file. If you are just inserting the php incude in a php page, then I can't imagine why it would do that. Link to comment https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/#findComment-548333 Share on other sites More sharing options...
MadnessRed Posted May 23, 2008 Author Share Posted May 23, 2008 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 https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/#findComment-548348 Share on other sites More sharing options...
gamefreak13 Posted May 23, 2008 Share Posted May 23, 2008 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 https://forums.phpfreaks.com/topic/106917-gets-changed-to-in-fwrite-script-how-do-i-stop-that/#findComment-548358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.