pcw Posted March 13, 2009 Share Posted March 13, 2009 Hi, this code does not work, and if i remove stripslashes, then it writes \\\ into the file. How can I get fwrite and striplslashes to work together? <?php if($_POST = 'submit') { $filename = $_POST['filename']; $temp_code = $_POST['template']; $fa = fopen( $filename, "w" ) or die("Error opening $filename"); fwrite(stripslashes( $fa, $temp_code )); fclose( $fa ); } ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/149237-solved-fwrite-and-stripslashes-prob/ Share on other sites More sharing options...
JonnoTheDev Posted March 13, 2009 Share Posted March 13, 2009 if($_POST['submit']) { $filename = $_POST['filename']; $temp_code = stripslashes($_POST['template']); $fa = fopen( $filename, "w" ) or die("Error opening $filename"); fwrite($fa, $temp_code); fclose( $fa ); } Also look at this line if($_POST = 'submit') { Change to if($_POST['submit']) { Quote Link to comment https://forums.phpfreaks.com/topic/149237-solved-fwrite-and-stripslashes-prob/#findComment-783703 Share on other sites More sharing options...
jackpf Posted March 13, 2009 Share Posted March 13, 2009 was in the process of writing this Yeah, do that. Atm, you're removing slashes from your filehandle as well; you only want it on your post data. Tbh, you should just turn off magic quotes in your php.ini. It's stupid. Quote Link to comment https://forums.phpfreaks.com/topic/149237-solved-fwrite-and-stripslashes-prob/#findComment-783704 Share on other sites More sharing options...
pcw Posted March 13, 2009 Author Share Posted March 13, 2009 Thats great guys, thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/149237-solved-fwrite-and-stripslashes-prob/#findComment-783721 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.