Skip to content

Instantly share code, notes, and snippets.

@matthijs166
Created February 9, 2018 18:35
Show Gist options
  • Save matthijs166/bef78f09149323ffefc0f8b1e7f4ea9b to your computer and use it in GitHub Desktop.
Save matthijs166/bef78f09149323ffefc0f8b1e7f4ea9b to your computer and use it in GitHub Desktop.
Escape a string make it save for saving
function MakeSafe($unsafestring)
{
$unsafestring= htmlentities($unsafestring, ENT_QUOTES);
if (get_magic_quotes_gpc())
{
$unsafestring= stripslashes($unsafestring);
}
$unsafestring= mysql_real_escape_string(trim($unsafestring));
$unsafestring= strip_tags($unsafestring);
$unsafestring= str_replace("\r\n", "", $unsafestring);
return $unsafestring;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment