Page 1 of 1
quick question - stripslashes & magic quotes...
Posted: Wed Jan 12, 2005 4:31 am
by batfastad
Our server has magic quotes set to 'on'
Is there anyway I can disable the magic quotes option on my ISP for just one script?
Also the stripslashes() function, does that remove all back slashes in the string?
So if someone typed...
example\example
Then the \ would get removed?
Or does stripslashes just get rid of the ones that are commenting out other characters?
Like these ' " \
Thanks
Ben
Posted: Wed Jan 12, 2005 5:00 am
by batfastad
OK so I think stripslashes remove all slashes.
Is there a way to just remove the slashes that are escaping characters after it?
I've tried this...
Code: Select all
// REPLACE ANY COMMENT SLASHES IN THE MESSAGE BODY
$messagestripped1 = str_replace("\''", "''", $message);
$messagestripped2 = str_replace(""e;", """, $messagestripped1);
But I'm getting errors...
Code: Select all
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /files/home1/dealerworld/dwc-content/eclubsubscribe.php on line 133
I don't want to remove any slashes if the user enters them, or even enters two of them in a row.
I thought the above code should work but it isn't.
Any ideas?
Thanks
Ben
Posted: Wed Jan 12, 2005 5:33 am
by Chris Corbyn
From what I can remember stripslashes should only remove the escping slashes - it shouldn't mess things up with backslashes that are supposed to be there.
I useed to use with Windows file paths where there would be C:\\MyWebs\\Somesite\\index.php etc to make it go to c:\Mywebs\somesite\index.php since example\example has no escaping backslashes it shouldn't play with it

Posted: Wed Jan 12, 2005 9:02 am
by feyd
coming in, example\example should look like example\\example. stripslashes() should bring it back to where it's supposed to be for general use.
Posted: Wed Jan 12, 2005 9:33 am
by ianlandsman
The best thing to do is use the function set_magic_quotes_runtime to disable magic quotes (or enable). Either way this function lets you set if quotes are escaped or not. This way you never have to guess if they are you simple set them the way you like them and then code the rest of your program with the runtime set to a known value.
http://us4.php.net/manual/en/function.s ... untime.php