Gruzin Posted July 24, 2006 Share Posted July 24, 2006 hi guys, I'll explain it shortly: I've got a simple form on my site, so I can input some text there. (text is stored in the text file). and I've got a little problem there, when I input the text, like this one: [color=red]Here will be our text. I've included it in the text file.[/color], it's displayed in the following way:[color=red]Here will be our text. I\'ve included it in the text file.[/color], I mean it adds a backslash or something...any ideas how can I fix that, It really disturbs me, thanks. Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/ Share on other sites More sharing options...
hussain Posted July 24, 2006 Share Posted July 24, 2006 ude stripslashes() function Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62711 Share on other sites More sharing options...
Gruzin Posted July 24, 2006 Author Share Posted July 24, 2006 sorry, I don't understand... Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62713 Share on other sites More sharing options...
hussain Posted July 24, 2006 Share Posted July 24, 2006 use stripslashes() function beforee writning into file Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62716 Share on other sites More sharing options...
just-j Posted July 24, 2006 Share Posted July 24, 2006 if your wanting to echo it on the screen with php use echo stripslashes(baa\sdf\asd\fa\sdfasdfas\dfasdf\asdf);and it will say all that without the \ marks. dont make it take them out of your text file because you will run into problems when trying to display it on the screen because the \ mark escapes special characters.. for instance if you was to do somthing like this$var = this is what i've done;then php sees that ' as codeso doing this$var = this is what i\'ve done;then this is ok. but to display it use the echo stripslashes($var); Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62717 Share on other sites More sharing options...
Gruzin Posted July 24, 2006 Author Share Posted July 24, 2006 thanks guys, I'll try:) Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62720 Share on other sites More sharing options...
Gruzin Posted July 24, 2006 Author Share Posted July 24, 2006 It didn't work:( here is the code:<?php $link = "admin.php"; $linkShow = "Your info is saved"; stripslashes($text); $text = $_POST["text"]; $text_file = "text.txt"; $name_gax = file($text_file); //opens with array $text_open = fopen($text_file, "w+"); //open message file with write fputs($text_open, $text); fclose($text_open); echo "<a href='".$link."'>".$linkShow;?> Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62724 Share on other sites More sharing options...
kenrbnsn Posted July 24, 2006 Share Posted July 24, 2006 Did you read the manual (http://www.php.net/stripslashes) on how to use the function? You need to store the results of the function in a variable (or the same one) for it to have any affect.Ken Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62727 Share on other sites More sharing options...
Gruzin Posted July 24, 2006 Author Share Posted July 24, 2006 how can I store the results in a variable, the text actually is written in the form? Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62728 Share on other sites More sharing options...
kenrbnsn Posted July 24, 2006 Share Posted July 24, 2006 You modify your code as follows:[code]<?php $link = "admin.php"; $linkShow = "Your info is saved";// stripslashes($text); <--- This the line that didn't do anything meaning full, see how it is done in the next line $text = stripslashes($_POST["text"]); $text_file = "text.txt"; $name_gax = file($text_file); //opens with array $text_open = fopen($text_file, "w+"); //open message file with write fputs($text_open, $text); fclose($text_open); echo "<a href='".$link."'>".$linkShow;?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62753 Share on other sites More sharing options...
Gruzin Posted July 24, 2006 Author Share Posted July 24, 2006 kenrbnsn thank u very much, your help was very necessary for me:) Link to comment https://forums.phpfreaks.com/topic/15462-a-little-problem/#findComment-62770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.