note 38781 added to function.get-magic-quotes-gpc
| From: | eric_tayloratsymbolmorgan-caindotcom at rn2 dot php dot net | Date: | Tue, 06 Jan 2004 23:56:23 +0000 |
| Subject: | note 38781 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63033@lists.php.net to get a copy of this message | ||
This may be a somewhat unique approach (and it certainly seems to work)--basically, I reasoned the
only time that I'm having trouble with magic_quotes_gpc is when some of my data came from
$_POST and some of it came fresh off the SQL database. In that case, I have a mix of magic-quoted
and non-magic-quoted data, which is the sticky issue.
My solution is to ereg for any unslashed single-quotes in my variables before attempting an SQL
insert or update with my variables:
function maybeslash( &$element ) {
if( is_array( $element ) ) {
// recurse any arrays in our variable
array_map( "maybeslash", $element );
} else {
// if our variable has a single-quote with no slash b4 it, addslash
if( ereg( "^']'", $element ) ) {
$element = addslashes( $element );
}
}
}
When it's over, everything is magic-quote compatiblized... :)
----
Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38781
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38781&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38781&report=yes
Search -- http://master.php.net/manage/user-notes.php