Revision: 33427
Updated Code
at October 9, 2010 20:47 by stz184
Updated Code
function str2db($input, $strip_tags=true) { if(is_array($input)) { foreach($input as $key => $value) { $input[$key] = str2db($value); } } else { if(get_magic_quotes_gpc()) { if(ini_get('magic_quotes_sybase')){ $input = str_replace("''", "'", $input); } else { $input = stripslashes($input); } } if($strip_tags) { $input = strip_tags($input); } $input = mysql_real_escape_string($input); $input = trim($input); } return $input; }
Revision: 33426
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 8, 2010 18:18 by stz184
Initial Code
function str2db($input, $strip_tags=true) { if(is_array($input)) { foreach($input as $key => $value) { $input[$key] = str2db($value); } } else { if(get_magic_quotes_gpc()) { if(ini_get('magic_quotes_sybase')){ $input = str_replace("''", "'", $input); } else { $input = stripslashes($input); } } if($strip_tags) { $input = strip_tags($input); } $input = mysql_real_escape_string($input); } return trim($input); }
Initial URL
Initial Description
This function can be used to sanitize single string variable or massive like POST, GET, COOKIE. It performs magic quotes gpc check, strip tags, trim and escape the dangerous signs with mysql_real_escape_string.
Initial Title
String to database (sanitize string for inserting in database)
Initial Tags
post
Initial Language
PHP