...

View Full Version : stripslashes .... thing. Removing \ from multiple chars



pippin418
03-21-2010, 09:57 AM
So. If I type:
The quick brown fox was too freakin' lazy to jump over the lazy dog.
I get:
The quick brown fox was too freakin\' lazy to jump over the lazy dog.
(I know the new PHP stops this, but I can't upgrade)
So if I use the command to remove slashes I get rid of all slashes (which I don't want to do), so I tried str_replace

$str3 = array("\\"", "\\'", "\\\");
$str4 = array("", "", "");
$str = str_replace($str3,$str4,$_POST['str']);
But that obviously didn't work. So how would I replace \" or \' or \\ with nothing?

(in the php above, it removed my single quote thing. it looked like this without and spaces: \ \ ' )

SKDevelopment
03-21-2010, 12:21 PM
Try:


$str = get_magic_quotes_gpc()?stripslashes($_POST['str']):$_POST['str'];

SKDevelopment
03-21-2010, 12:27 PM
Or you could try to disable magic_quotes_gpc via .htaccess (provided your HTTP server is Apache). You could try to add the following like to .htaccess for it:


php_flag magic_quotes_gpc Off

Of course before doing any changes in .htaccess, make a backup copy of your original .htaccess somewhere.

pippin418
03-22-2010, 03:36 AM
Thank you SKDevelopment. That worked like a charm.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum