Return to Snippet

Revision: 43672
at March 29, 2011 12:17 by zubacris


Initial Code
function mysql_prep($value) {
	$magic_quotes_active = get_magic_quotes_gpc();
	$new_enough_gpc = function_exists("mysql_real_escape_string"); // i.e, PHP >= v4.3.0
	
	if ($new_enough_gpc) {
		if($magic_quotes_active) {$value = stripslashes($value);}
		$value = mysql_real_escape_string($value);
	}
	else {
		if (!$magic_quotes_active) {$value = addslashes($value);}
	}
	return $value;
}

Initial URL

                                

Initial Description

                                

Initial Title
mysql_prep function

Initial Tags
mysql, textmate

Initial Language
Other