Backslashes in my text...

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
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Backslashes in my text...

Post by Jim »

http://www.aoe2.com/!scripts/filesubmission/test.php

When I input text in that box with an apostrophe, it backslashes it. How do I fix that?

Thanks!
User avatar
amnuts
Forum Newbie
Posts: 16
Joined: Fri Jun 14, 2002 1:48 pm
Contact:

Re: Backslashes in my text...

Post by amnuts »

Jim wrote:http://www.aoe2.com/!scripts/filesubmission/test.php

When I input text in that box with an apostrophe, it backslashes it. How do I fix that?

Thanks!
Hi,

This is happening because your have magic_quotes on. You could turn this off in the php.ini file, but that's not always optimum. Instead what you could do is use a little function that checks for the magic_quotes and removes them (or adds them, of course) as needs be. The function to check for magic_quotes if get_magic_quotes_gpc().

Such as:

Code: Select all

function stripGPC($foo)
{
	if (!get_magic_quotes_gpc()) return $foo;
	else return stripslashes($foo);
}
I've put this kind of functions (which also works on any dimension array), along with a number of others in a class which can be found at:

http://andyc.users.phpclasses.org/brows ... e/1027.htm

Andy
Post Reply