lib/SafeSQL.php
function _sql_escape($link_id, $var) {
        if(is_array($var)) {
            foreach($var as $_element) {
                $_newvar[] = $this->_sql_escape($link_id, $_element);
            }
            return $_newvar;
        }
        if(function_exists('mysqli_real_escape_string')) {
            return $link_id->real_escape_string($var);
        } else {
            return addslashes($var);
        }
    }
function _sql_escape($link_id, $var) {
        if(is_array($var)) {
            foreach($var as $_element) {
                $_newvar[] = $this->_sql_escape($link_id, $_element);
            }
            return $_newvar;
        }
        if(function_exists('mysqli_real_escape_string')) {
            return $link_id->real_escape_string($var);
        } else {
            return addslashes($var);
        }
    }
/*======================================================================*\
Function: _sql_escape
Purpose:  recursively escape variables/arrays for SQL use
\*======================================================================