mazman13 Posted September 12, 2006 Share Posted September 12, 2006 I'm saving text to a TEXT file instead of a database, so if i use "" or '' to say something, PHP adds the \ before it. I've tried the stripslashes($string) before it loads to the text file and when I call the info (not both at the same time)...but the \ is still there.Any ideas? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 12, 2006 Share Posted September 12, 2006 you may have added slashes twice to the database...try[code]$string=str_replace("\",'',$string);echo $string;[/code]that should do the job..Liam Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 12, 2006 Share Posted September 12, 2006 [code]<?phpfunction magic_strip($str){ if (get_magic_quotes_gpc()) $str = stripslashes($str); return $str;}$file = fopen('/path/to/file.txt', 'w');frwite($file, magic_strip($_POST['text']));fclose($file);?>[/code] Quote Link to comment Share on other sites More sharing options...
mazman13 Posted September 12, 2006 Author Share Posted September 12, 2006 That script works. Thanks. Can you explain it? I think I have an idea, but I just want to make sure. Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 12, 2006 Share Posted September 12, 2006 you only need to stripslashes() post data if magic_quotes are on :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.