Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php function mysqli_prep( $value ) {
  2.         $magic_quotes_active = get_magic_quotes_gpc();
  3.         $new_enough_php = function_exists( "mysqli_real_escape_string" ); // i.e. PHP >= v4.3.0
  4.         if( $new_enough_php ) { // PHP v4.3.0 or higher
  5.             // undo any magic quote effects so mysqli_real_escape_string can do the work
  6.             if( $magic_quotes_active ) { $value = stripslashes( $value ); }
  7.             $value = mysqli_real_escape_string( $value );
  8.         } else { // before PHP v4.3.0
  9.             // if magic quotes aren't already on then add slashes manually
  10.             if( !$magic_quotes_active ) { $value = addslashes( $value ); }
  11.             // if magic quotes are active, then the slashes already exist
  12.         }
  13.         return $value;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement