php - 弃用 : mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO

标签 php mysql pdo mysqli

<分区>

I'm actually looking for an alternative to mysql_real_escape_string to solve this error. in php 5.4 it worked perfectly but no longer in 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;
}
}

最佳答案

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

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

关于php - 弃用 : mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22152019/

相关文章:

php - 对于大数据集,哪个更快? mysql、mysqli 还是 PDO?

php - 数组元素包裹所有元素

mysql - 自己更新表 MySQL

Mysql按功能分组

php - "The active result contains no fields"将 PDO 与 MS SQL 结合使用

php - 使用 PDO 语句登录表单 PHP

php - 数据库表自定义命名约定 Laravel Eloquent

php - 自动登录 Google Analytics?

php - Mysql 多个 LIKE 与 "AND"

php - PDO - 调用非对象上的成员函数 fetch()?