PDO return escaping slash, how to remove it?

I make some choices with the PDO object, but after the fetch result, I got the line from escaped ' to \' , how can I disable it?

+7
php pdo
source share
3 answers

It looks like you might be having problems with Magic Quotes . You can disable them by following the instructions here . It is highly recommended that you turn them off, rather than bypassing them, using the function to just cut slashes.

+8
source share

Looks like you included magic quotes .

In fact, you should disable magic quotes from php.ini .

Or from within the script, you can process it like this:

 if (get_magic_quotes_gpc()) { $str = stripslashes($str); } 

Now you can usually use the $str variable.

+2
source share

I worked on shared hosting, I did not have access to php.ini - ini_set() will not work either. This snippet worked like a charm: [source ]

 // since PHP 5 if (get_magic_quotes_gpc()) { function stripslashes_gpc(&$value) { $value = stripslashes($value); } array_walk_recursive($_GET, 'stripslashes_gpc'); array_walk_recursive($_POST, 'stripslashes_gpc'); array_walk_recursive($_COOKIE, 'stripslashes_gpc'); array_walk_recursive($_REQUEST, 'stripslashes_gpc'); } 
+1
source share

All Articles