I am doing some select with PDO object, but after fetch
result, I got string with escaped '
to \'
, how can I disable that?
views:
78answers:
2
A:
Looks like you have magic quotes turned on.
You should actually turn off the magic quotes from php.ini.
Or from within script, you can handle it like this:
if (get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
Now you can use the $str
variable normally.
Sarfraz
2010-08-01 14:21:18
It's probably best to check if magic_quotes is actually enabled before stripping slashes, otherwise you'll be removing slashes that are meant to be left intact.
tdammers
2010-08-01 14:22:28
@tdammers: I updated the answer with this before this comment, thanks anyways :)
Sarfraz
2010-08-01 14:23:59
+4
A:
It seems like you might be having some trouble with Magic Quotes. You can disable them by following the instructions here. It's highly recommended that you disable them instead of sidestepping them by using a function to just strip the slashes out.
Sam152
2010-08-01 14:21:32