Advertisement
The_KGB

[PHP] Basic Escape SQLi

Mar 17th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. <?php
  2. /** Basic SQLi protection by escaping
  3. *\
  4. function sanitize ($value)
  5. {
  6. if( get_magic_quotes_gpc() )
  7. {
  8. $value = stripslashes( $value );
  9. }
  10. if( function_exists( “mysql_real_escape_string” ) )
  11. {
  12. $value = mysql_real_escape_string( $value );
  13. }
  14. else
  15. {
  16. $value = addslashes( $value );
  17. }
  18. return $value;
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement