Jump to content

Archived

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

Gruzin

A little problem

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.

Share this post


Link to post
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);

Share this post


Link to post
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;
?>

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
how can I store the results in a variable, the text actually is written in the form?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
kenrbnsn thank u very much, your help was very necessary for me:)

Share this post


Link to post
Share on other sites

×

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.