Page 1 of 1

prob with replacing "

Posted: Sat Aug 02, 2003 9:58 am
by Gi7mo!
i build an cms.... for a website....
but if i save the text wich the user has typed and there is an " in the php replaces me the " to an \"
the i wrote a little script to replace that...
but now php makes me out of the " an ""

heres the code...
$copytext = the text wich i want to save

[syntax=php]$a = chr(34); //assign ascii \
$b = chr(92); //assign ascii "
$c = $a.$b; //merge ascii \"
$d = "&quot";
$e = chr(59); //assign ascii ;
$f = $d.$e; //merge
$g = chr(7); //assign ascii linefeed
$h = explode($g, $copytext); //delete linefeed
$w = str_replace($b, $f, $h); //replace \" -> "
$z = "../_base_include/";
$z .= $save;
$z .= ".txt";
$x = fopen($z , "w");
$test = $w[0];
fwrite($x, $test);
fclose($x);[/syntax]

can anyone tell me what is wrong with it ?!?

Posted: Sat Aug 02, 2003 10:37 am
by Gianni_T

Posted: Sat Aug 02, 2003 10:41 am
by Gi7mo!
u missunderstand me...
i don't want these slashes before the " ....
i want to remove them, because it is for an website...
and it looks a little dumb if there is an \" visible for the user....

Posted: Sat Aug 02, 2003 11:05 am
by Gianni_T
Sorry :oops: ,
perhaps you are interested in "stripslashes"
http://it.php.net/manual/en/function.stripslashes.php

Posted: Sat Aug 02, 2003 11:29 am
by Gi7mo!
np män, but now he only gives me an R back.....

$x = fopen($z , "w");
$v = stripslashes($x);
$xy = $v[0];
fwrite($x, $xy);
fclose($x);

<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>.....
:cry:

Posted: Sat Aug 02, 2003 11:39 am
by nielsene
fopen gives you back a file pointer, not the contents of the file, you want to look at the fread or similar functions to get the contents of the file into a variable before calling stripslashes.

Posted: Sat Aug 02, 2003 12:26 pm
by Gi7mo!
thanks a very very lot män...
it works !!!!
:D *smile*