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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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