How can I fix this error? Deprecated: mysql_escape_string (): this function is deprecated; Use mysql_real_escape_string () instead

advertisements

I get stuck on the following:

Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/xtremeso/public_html/mp3/includes/class/_class_mysql.php on line 116

        function safesql( $source )
        {
            if ($this->db_id) return mysqli_real_escape_string ($this->db_id, $source);
            else return mysql_escape_string($source);
        }

I already tried to mysql_escape_real_string but that doesnt solve the issue. And ignoring php error messages via .htacces file doesnt work either


the error message clearly said it .

change this

 else return mysql_escape_string($source); // you are using mysql here

to

 else return mysqli_real_escape_string($source); //will be mysqli

OBS: you should switch to PDO or MYSQLI as MYSQL mysql_real_escape_string will also be deprecated :)

you are mixing Between mysqli and mysql .

EDIT: from your second error.

  mysqli_real_escape_string ($link ,$source )  // $link is your connection variable

ref