bgeorgeus Posted January 25, 2007 Share Posted January 25, 2007 First of all i am a beginner to PHP and i have a very simple script that writes the contents of a text box with is HTML code to a text file. The file is then read by another script which displays the output to the screen.Whenever i use in the text box ex "<h1>George's House</h1>" it writes "<h1>George\'s House</h1>" to the file leaving annoying backslashes in my web page. How can i keep the script from writing these backslashes.My code:Writing the file$code = $_POST['text'];$file = fopen("../index.txt","w");fwrite($file,"$code");fclose($file);Reading the file$file = fopen("index.txt","r"); while(!feof($file)){ echo fgets($file);} Link to comment https://forums.phpfreaks.com/topic/35608-string-question/ Share on other sites More sharing options...
trq Posted January 25, 2007 Share Posted January 25, 2007 Use [url=http://php.net/stripslashes]stripslashes[/url]() when gathering your post data. eg;[code=php:0]$code = stripslashes($_POST['text']);[/code] Link to comment https://forums.phpfreaks.com/topic/35608-string-question/#findComment-168655 Share on other sites More sharing options...
bgeorgeus Posted January 25, 2007 Author Share Posted January 25, 2007 Thanks I'm slash free Link to comment https://forums.phpfreaks.com/topic/35608-string-question/#findComment-168661 Share on other sites More sharing options...
Hypnos Posted January 25, 2007 Share Posted January 25, 2007 If you turn off magic_quotes_gpc, it won't do that. It's for SQL injection protection for people who write insecure SQL querys. Link to comment https://forums.phpfreaks.com/topic/35608-string-question/#findComment-168698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.