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? Link to comment https://forums.phpfreaks.com/topic/20475-need-help-with-being-loaded-before-a/ 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 Link to comment https://forums.phpfreaks.com/topic/20475-need-help-with-being-loaded-before-a/#findComment-90264 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] Link to comment https://forums.phpfreaks.com/topic/20475-need-help-with-being-loaded-before-a/#findComment-90266 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. Link to comment https://forums.phpfreaks.com/topic/20475-need-help-with-being-loaded-before-a/#findComment-90483 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 :) Link to comment https://forums.phpfreaks.com/topic/20475-need-help-with-being-loaded-before-a/#findComment-90548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.