Jump to content

A little problem


Gruzin

Recommended Posts

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

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 code
so 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

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

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

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.