不推荐使用:mysql_real_escape_string():不推荐使用mysql扩展,将来会删除它:使用mysqli或PDO

时间:2014-03-03 16:29:44

标签: php mysql pdo mysqli

  

我实际上是在寻找mysql_real_escape_string的替代品   解决这个错误。   在PHP 5.4它完美但不再在PHP 5.5

$this->mysqli = new mysqli($this->host, $this->user, $this->pass, $this->name);
// in class user
public function __set($p_sProperty, $p_vValue)
        {   
            switch($p_sProperty)
            {    
// this is marked as the error
case "Email":
             $this->Email = **mysql_real_escape_string**($p_vValue); 
                break;
}
}

1 个答案:

答案 0 :(得分:11)

您使用MySQLi,请使用mysqli_real_escape_string()

$this->Email = $this->mysqli->real_escape_string($p_vValue);