Last active
April 13, 2016 20:07
-
-
Save igoralves1/9be2cdab5623bf790e590b69d0d12ef2 to your computer and use it in GitHub Desktop.
PHP - Filter a string to be saved in the MySql database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function tool_string_filter($str) { | |
if(is_null($str)){ | |
return "NULL"; | |
} | |
else{ | |
if(is_numeric ($str)){ | |
return $str; | |
} | |
else{ | |
return "\"".mysql_escape_string(utf8_encode($str))."\""; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment