Page 1 of 1

fputs adds characters?

Posted: Wed Jul 13, 2005 3:24 pm
by darkzerox
hi.

i'm creating a simple form which reads text from a file, and displays it in a textbox. the user can then edit it, hit the save button, and the file should be editted.

the main problem i'm having is that everywhere there is a quote, it adds a '\' infront of it. i believe the problem is with the following code.

Code: Select all

$myfile = fopen($p . ".txt","w");
		fputs($myfile,$_POST['editbox']);
		fclose($myfile);
any suggestions?

Posted: Wed Jul 13, 2005 3:39 pm
by onion2k
You've got GPC magic quotes switched on. What this does is escape all the quotes coming from Get, Post, and Cookie data from the user. It's done so that noone can do an SQL injection attack if you're using a database. It's tremendously annoying and gets in the way alot.

Fortunately running data through stripslashes() ( http://uk.php.net/stripslashes ) should fix it.