Slashes appear in POST vars even with magic_quotes_gpc = off

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
fionex
Forum Newbie
Posts: 3
Joined: Mon Nov 17, 2008 9:13 am

Slashes appear in POST vars even with magic_quotes_gpc = off

Post by fionex »

Hi,

For some reason, only a couple of my scripts are having a weird problem where they automatically add slashes to any post variable (but not get variables). The funny thing is, magic_quotes_gpc and magic_quotes_runtime are off in my php.ini and phpinfo.php indicates off for both. Why does it only affect post variables but not get variables? Why is it only affecting my php classes, but not my test scripts?

Any ideas would be appreciated.

Thanks
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Slashes appear in POST vars even with magic_quotes_gpc = off

Post by aceconcepts »

Do the variables containt special characters such as apostophes?

Take a look at stripslashes()
fionex
Forum Newbie
Posts: 3
Joined: Mon Nov 17, 2008 9:13 am

Re: Slashes appear in POST vars even with magic_quotes_gpc = off

Post by fionex »

Yes they have apostrophes and I wanted to use stripslashes. The weird part is that my scripts just started having slashes in post vars out of the blue.

So the last thing I want to do is modify hundreds of lines and then have to revert. Would you know why the scripts would just start adding slashes to just post vars? I do interact with a database, and I use mysql_real_escape_string but even before I use it, there's slashes just on the post vars.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Slashes appear in POST vars even with magic_quotes_gpc = off

Post by aceconcepts »

Do the slashes keep on adding (mutiply) each time you post from your form?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Slashes appear in POST vars even with magic_quotes_gpc = off

Post by Eran »

in your script run

Code: Select all

 
var_dump( get_magic_quotes_gpc() );
 
If the result is 1 you definitely have magic_quotes turned on somehow

Is this happening on a local machine or a remote server? and it it's on a remote, is it a shared account?
fionex
Forum Newbie
Posts: 3
Joined: Mon Nov 17, 2008 9:13 am

Re: Slashes appear in POST vars even with magic_quotes_gpc = off

Post by fionex »

The get_magic_quotes function returns 0. Yes, it adds more slashes everytime you submit the form. It only happens in some scripts. Suppose I add a form to one of my scripts and just dump the post variables (print $_POST['test'];), they'll have slashes in them. But if I create a new file in the same directory with the same form, I don't have this problem. LOL. I never enabled magic quotes in any script I write, so it's weird!
Post Reply