Return to Snippet

Revision: 2137
at January 3, 2007 11:07 by nicolaspar


Updated Code
//mysqli_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysqli_real_escape_string( $conn, $value );
	return $value;
}
#echo inSql("testeando '"); 

//mysql_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysql_real_escape_string( $value );
	return $value;
}
#echo inSql("testeando '");

#Diferentes versiones de php:
function inSql ($string) {
   global $conn,
   if(version_compare(phpversion(),"4.3.0")=="-1") {
     mysql_escape_string($string);
   } elseif ($conn) {
     mysql_real_escape_string($string,$conn);
   } else { return false; }
}

Revision: 2136
at January 3, 2007 11:03 by nicolaspar


Initial Code
//mysqli_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysqli_real_escape_string( $conn, $value );
	return $value;
}
echo inSql("testeando '"); 

//mysql_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysql_real_escape_string( $value );
	return $value;
}
echo inSql("testeando '");

Initial URL

                                

Initial Description

                                

Initial Title
PHP - Limpiar inyección sql

Initial Tags
sql

Initial Language
PHP