Posted By

zubacris on 03/29/11


Tagged

mysql textmate quotes magic addslashes prep


Versions (?)

mysql_prep function


 / Published in: Other
 

  1. function mysql_prep($value) {
  2. $magic_quotes_active = get_magic_quotes_gpc();
  3. $new_enough_gpc = function_exists("mysql_real_escape_string"); // i.e, PHP >= v4.3.0
  4.  
  5. if ($new_enough_gpc) {
  6. if($magic_quotes_active) {$value = stripslashes($value);}
  7. $value = mysql_real_escape_string($value);
  8. }
  9. else {
  10. if (!$magic_quotes_active) {$value = addslashes($value);}
  11. }
  12. return $value;
  13. }
  14.  

Report this snippet  

You need to login to post a comment.