ezSQL_mysqli::escape PHP Method

escape() public method

******************************************************************** Format a mySQL string correctly for safe mySQL insert (no mater if magic quotes are on or not)
public escape ( $str )
    function escape($str)
    {
        // If there is no existing database connection then try to connect
        if (!isset($this->dbh) || !$this->dbh) {
            $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport);
            $this->select($this->dbname, $this->encoding);
        }
        if (get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return $this->dbh->escape_string($str);
    }

Usage Example

Beispiel #1
0
function makepwd($password)
{
    $db = new ezSQL_mysqli(db_user, db_password, db_name, db_host);
    if ($db->get_var("SELECT option_value FROM site_options where option_name = 'encrypted_passwords';") == "yes") {
        //if encryption is ON
        include "includes/PasswordHash.php";
        $hasher = "*";
        $hasher = new PasswordHash(8, false);
        $return_pass = $hasher->HashPassword($password);
        //if encryption is OFF
    } else {
        $return_pass = trim($db->escape($password));
    }
    return $return_pass;
}
All Usage Examples Of ezSQL_mysqli::escape