Posted By

nicolaspar on 01/03/07


Tagged

sql injection - inyeccin


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


PHP - Limpiar inyección sql


 / Published in: PHP
 

  1. //mysqli_xxx
  2. function inSql($value){
  3. global $conn;
  4. if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
  5. $value = mysqli_real_escape_string( $conn, $value );
  6. return $value;
  7. }
  8. #echo inSql("testeando '");
  9.  
  10. //mysql_xxx
  11. function inSql($value){
  12. global $conn;
  13. if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
  14. $value = mysql_real_escape_string( $value );
  15. return $value;
  16. }
  17. #echo inSql("testeando '");
  18.  
  19. #Diferentes versiones de php:
  20. function inSql ($string) {
  21. global $conn,
  22. if(version_compare(phpversion(),"4.3.0")=="-1") {
  23. } elseif ($conn) {
  24. mysql_real_escape_string($string,$conn);
  25. } else { return false; }
  26. }

Report this snippet  

You need to login to post a comment.