Mr Confused
07-30-2005, 12:30 AM
Well you probably got the whole story in the subject. The script I have to write to a text file is putting a slash in front of every ( ' ) without the parentheses. How do I avoid this? I'm sure its simple.
![]() | View Full Version : HELP! Slashes in front of every quotation Mr Confused 07-30-2005, 12:30 AM Well you probably got the whole story in the subject. The script I have to write to a text file is putting a slash in front of every ( ' ) without the parentheses. How do I avoid this? I'm sure its simple. masfenix 07-30-2005, 12:31 AM stripslashes() should work for u Mr Confused 07-30-2005, 01:19 AM IT STILL ISNT WORKING :'( the variable $contents is input from a form. <?php // thedate $today = date("m.d.y"); // takes out evil slashes before quotations stripslashes($contents); // sets variable for writing to file $new_contents = "<b> $today </b><br> [$name] <br> $contents <br>"; $current_contents = file("guestbook.txt"); //Open the file in "w" mode, essentially deleting it $fp = fopen("guestbook.txt","w"); //Write the new content first, then the old content fwrite($fp,$new_contents.implode("",$current_contents)); //Close it fclose($fp); // redirects page echo "<script language='javascript'>window.location='write_confirm.htm'</script>"; ?> Burhan 07-30-2005, 01:50 AM Please read the documentation for stripslashes() (http://php.net/stripslashes) before you yell 'it still isnt working'. Mr Confused 07-30-2005, 02:01 AM jee thanks but i did. Mr Confused 07-30-2005, 02:03 AM eh sorry. i needed a drink. i've got it now. not exactly how i planned to implicate the code but whatever works will have to do. Sizzly 07-30-2005, 04:01 AM stripslashes() RETURNS the value, doesn't actually make changes to the variable... which means you need to do: $contents=stripslashes($contents); zoldar 07-30-2005, 04:13 AM The source of the problem: http://www.php.net/magic_quotes |