Page 1 of 1
Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 9:40 am
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
Re: Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 9:45 am
by aceconcepts
Do the variables containt special characters such as apostophes?
Take a look at stripslashes()
Re: Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 9:53 am
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.
Re: Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 10:01 am
by aceconcepts
Do the slashes keep on adding (mutiply) each time you post from your form?
Re: Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 4:12 pm
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?
Re: Slashes appear in POST vars even with magic_quotes_gpc = off
Posted: Mon Nov 17, 2008 4:19 pm
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!