tags:

views:

78

answers:

2

I am doing some select with PDO object, but after fetch result, I got string with escaped ' to \', how can I disable that?

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
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
@tdammers: I updated the answer with this before this comment, thanks anyways :)
Sarfraz
+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