Re: DataObjects setFrom and DB:quote woes

From: Date: Mon, 05 Apr 2004 01:09:28 +0000
Subject: Re: DataObjects setFrom and DB:quote woes
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11617@lists.php.net to get a copy of this message
Jacob Singh wrote:
2. quote(); This one is really pissing me off. When I submit a text field, DataObjects insists on putting tons of extra backslashes in. Every time I submit I get a few new backslashes, they seem to grow exponetially.
I suspect the magic_quotes are on in your php.ini. If you are not able to edit php.ini directly, try to use the following code snippet at the top of your scripts, taken from the PHP manual: // ********************************************* // remove magic quotes function no_magic_quotes_gpc(&$var) {
       if (is_string($var)) {
           $var = stripslashes($var);
       } elseif (is_array($var)) {
           foreach ($var as $key => $value) {
               no_magic_quotes_gpc($var[$key]);
           }
       } elseif (is_object($var)) {
           foreach (get_object_vars($var) as $key => $value) {
           no_magic_quotes_gpc($var->$key);
       }
} } if (get_magic_quotes_gpc()) { no_magic_quotes_gpc($_GET); no_magic_quotes_gpc($_POST); no_magic_quotes_gpc($_COOKIE); } My experiences show that you won't have any problems with quotes when using PEAR if: - you turn off magic quotes in php.ini or use the above code snippet - when displaying contents from the database to html forms (<input type=text> etc..), display values using nl2br(htmlspecialchars($value)) instead of putting $value directly into <input type=text value="$value"> Regards, Norbert

« previous php.pear.general (#11617) next »