简体   繁体   English

mysql_real_escape_string和特殊字符

[英]mysql_real_escape_string and special characters

I'm working on OpenCart to make an application for importing data from an ERP. 我正在使用OpenCart制作一个用于从ERP导入数据的应用程序。 In some descriptions of the items is sometimes used the character "°" (degree). 在某些项目的描述中,有时会使用字符“°”(度)。 The application of insert of the standard software in question used "mysql_real_escape_string" and accepts the character specified above. 所讨论的标准软件的插入应用程序使用“ mysql_real_escape_string”,并接受上面指定的字符。 In my application I use the same function, but the function imports only the previous characters before of "°" and then moves on to the next product. 在我的应用程序中,我使用相同的函数,但是该函数仅导入“°”之前的先前字符,然后继续处理下一个产品。 I've tried to debug and the variable contains the rightdescription. 我尝试调试,并且变量包含rightdescription。 Certenly there's an error, but I don't understand where is. 确实有一个错误,但是我不知道在哪里。 Has anyone had a similar problem and solved it? 有谁遇到过类似的问题并解决了吗? How? 怎么样?

thanks bye 谢谢再见

This is my code 这是我的代码

$this->db->query("UPDATE " . DB_PREFIX . "product_description SET name = '" .  $this->db->escape($description_it) . "' WHERE product_id = '" . (int)$product_id  . "' AND language_id = '2'");

and this is the function of Opencart 这是Opencart的功能

public function escape($value) {
    if ($this->link) {
        return mysql_real_escape_string($value, $this->link);
    }
}

reverse params: 反向参数:

string mysqli_real_escape_string ( mysqli $link , string $escapestr ) 字符串mysqli_real_escape_string(mysqli $ link,字符串$ escapestr)

you need change your rows: 您需要更改行:

 mysql_real_escape_string($this->link, $value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM