Page 1 of 1

[SOLVED] Linux automatically adding slashes

Posted: Wed Jul 06, 2005 10:30 pm
by anjanesh
Hi
I've come across this many times.
Im coding on WinXP (Apache) and uploading the scripts to a Linux Server.

If I send some data in the form of GET Linux is automatically adding slashes for which I have to do $_GET['a'] = stripslashes($_GET['a'])

test.php?a=h7w%C9%C2%22%26%C2N%7C%E5w%ED5

echo $_GET['a'];

On WinXP

Code: Select all

h7wÉÂ&quote;&ÂN|åwí5
On the Server (Linux)

Code: Select all

h7wÉÂ\&quote;&ÂN|åwí5
" converted to \"

All this time I thought that I'll need to use stripslashes() only after doing addslashes().
But now it seems I'll need to stip them even when I dont add them because Linux is adding them automatically.

What if the original string is h7wÉÂ\"&ÂN|åwí5 ?
stripslashes will work in Linux as the string will be h7wÉÂ\\\"&ÂN|åwí5 and the final string will be h7wÉÂ\"&ÂN|åwí5
But the same code on Windows will have the final string as h7wÉÂ"&ÂN|åwí5 getting rid of the \

Any idea on this ?

Thanks

Posted: Thu Jul 07, 2005 12:12 am
by andre_c
maybe magic_quotes is on:
http://php.net/magic_quotes

Posted: Thu Jul 07, 2005 12:42 am
by anjanesh
Ah..according to phpinfo
magic_quotes_gpc is On

How do I switch it off for my script ?

Thanks

Posted: Thu Jul 07, 2005 4:02 am
by shiznatix
you can strip_slashes();

Posted: Thu Jul 07, 2005 6:51 am
by timvw
It's all exlained here: http://www.php.net/magic_quotes

Posted: Thu Jul 07, 2005 7:38 am
by anjanesh
Thanks. Solved.

Code: Select all

ini_set("magic_quotes_gpc","Off");
_quotes_gpc","Off");ic_quotes_gpc","Off");php]ini_set("magic_quotes_gpc","Off");ini_set("magic_quotes_gpc","Off");