Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i solve this error? Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead [closed]

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

like image 559
FlikFlak Avatar asked Nov 16 '25 13:11

FlikFlak


2 Answers

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

like image 196
echo_Me Avatar answered Nov 18 '25 06:11

echo_Me


you need to connect mysql to the database before you use mysql_real_escape_string, this function doesn't work without mysql being connected to database.

like image 35
Sourabh Avatar answered Nov 18 '25 06:11

Sourabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!