fputs adds characters?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
darkzerox
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 3:20 pm

fputs adds characters?

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
Post Reply