SQL escape string function
Escapes special characters in a string for use in an SQL statement. howewer it check get_magic_quotes_gpc function is enable or no. if true , it strips string from slashes and escaped string from special characters in a string for use in an SQL statement.
function sql_escape_string( $str, $conn = '' ) { if ( get_magic_quotes_gpc() ) $str = stripslashes( $str ); //check if this function exists if ( function_exists( "mysql_real_escape_string" ) and $conn ) $str = mysql_real_escape_string( $str, $conn ); else $str = addslashes( $str ); //for PHP version < 4.3.0 use addslashes return $str; }