Jump to content


Photo

A little problem


  • Please log in to reply
10 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 10:00 AM

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: Here will be our text. I've included it in the text file., it's displayed in the following way:
Here will be our text. I\'ve included it in the text file., I mean it adds a backslash or something...

any ideas how can I fix that, It really disturbs me, thanks.
I don't need your script, I'll try to write it myself

#2 hussain

hussain
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 July 2006 - 10:07 AM

ude stripslashes() function


#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 10:12 AM

sorry, I don't understand...
I don't need your script, I'll try to write it myself

#4 hussain

hussain
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 July 2006 - 10:23 AM

use stripslashes() function beforee writning into file


#5 just-j

just-j
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts

Posted 24 July 2006 - 10:24 AM

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);

#6 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 10:26 AM

thanks guys, I'll try:)
I don't need your script, I'll try to write it myself

#7 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 10:29 AM

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;
?>
I don't need your script, I'll try to write it myself

#8 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 July 2006 - 10:43 AM

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

#9 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 10:44 AM

how can I store the results in a variable, the text actually is written in the form?
I don't need your script, I'll try to write it myself

#10 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 July 2006 - 11:39 AM

You modify your code as follows:
<?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;
?>

Ken

#11 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 24 July 2006 - 12:19 PM

kenrbnsn thank u very much, your help was very necessary for me:)
I don't need your script, I'll try to write it myself




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users