Skip to content

Instantly share code, notes, and snippets.

@igoralves1
Last active April 13, 2016 20:07
Show Gist options
  • Save igoralves1/9be2cdab5623bf790e590b69d0d12ef2 to your computer and use it in GitHub Desktop.
Save igoralves1/9be2cdab5623bf790e590b69d0d12ef2 to your computer and use it in GitHub Desktop.
PHP - Filter a string to be saved in the MySql database
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