Monday, 20 March 2017

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






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;
}
}

Answer



You using MySQLi so use mysqli_real_escape_string():



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

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...