Handy Functions
I’ve become a big fan of using a ‘config’ file that I include at the beginning of all my PHP pages. Here I can set everything from global settings and variables, to site-wide functions…
One of the site-wide functions I use a lot sends an email if a script fails, i.e. do this and if it worked do…
Quick and handy function to purify data before entering into the database
function escape_data($data){
$data = mysql_escape_string(trim($data));
$data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
return = $data;
}
//
// Convert a 'safe' url into words, for display on the page or inserting into a database
//
function purifyURL($url){
$url = trim($url);
$bannedChars = array("'",':','@');
$url = str_replace($bannedChars, '', $url);
$switchedChars = array('-','.','_');
$url = str_replace($…