evCleanSQL | cleans a SQL query


/ Published in: PHP
Save to your folder(s)

warning! not tested, I'm not an expert on this field


Copy this code and paste it in your HTML
  1. // name: evCleanSQL
  2. // version: v0.1
  3. // description: limpia un string para una consulta SQL
  4.  
  5. function evCleanSQL( $sql ) {
  6.  
  7. // si magic quotes está en ON
  8. $sql = stripslashes( $sql );
  9. endif;
  10.  
  11. // Si PHP > 4.3.0
  12. if ( function_exists( "mysql_real_escape_string" ) ) :
  13. $cleanSql = mysql_real_escape_string( $sql );
  14. else :
  15. // si PHP version > 4.3.0
  16. $cleanSql = addslashes( $sql );
  17. endif;
  18.  
  19. return $cleanSql;
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.