本文介绍了我如何解决这个错误?已弃用:mysql_escape_string():此函数已弃用;请改用mysql_real_escape_string()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入以下情况:



不推荐使用:mysql_escape_string():此功能已弃用;请改用mysql_real_escape_string()。在/home/xtremeso/public_html/mp3/includes/class/_class_mysql.php第116行

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

我已经尝试过mysql_escape_real_string,但这不能解决问题。
通过.htacces文件忽略php错误消息不能正常工作

解决方案

错误消息清楚地表示。 p>

更改此

  else return mysql_escape_string($ source); //你在这里使用mysql 

to

  else return mysqli_real_escape_string($ source); //将是mysqli 

OBS:您应该切换到PDO或MYSQLI作为MYSQL mysql_real_escape_string 也将被弃用:)



你正在混合mysqli和mysql之间。



编辑:从您的第二个错误。

  mysqli_real_escape_string($ link,$ source)/ / $ link是你的连接变量


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

这篇关于我如何解决这个错误?已弃用:mysql_escape_string():此函数已弃用;请改用mysql_real_escape_string()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:37