Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO [duplicate]

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;
}
}
like image 700
Yannick Avatar asked Dec 08 '22 09:12

Yannick


1 Answers

You using MySQLi so use mysqli_real_escape_string():

$this->Email = $this->mysqli->real_escape_string($p_vValue); 
like image 185
John Conde Avatar answered Dec 11 '22 11:12

John Conde