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

Yan*_*ick 2 php mysql mysqli pdo

我实际上是在寻找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;
}
}
Run Code Online (Sandbox Code Playgroud)

Joh*_*nde 13

你使用MySQLi所以使用mysqli_real_escape_string():

$this->Email = $this->mysqli->real_escape_string($p_vValue); 
Run Code Online (Sandbox Code Playgroud)