Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 搜索字符串中的通配符变为特殊字符_Php_Sql_Database_Codeigniter_Codeigniter 3 - Fatal编程技术网

Php 搜索字符串中的通配符变为特殊字符

Php 搜索字符串中的通配符变为特殊字符,php,sql,database,codeigniter,codeigniter-3,Php,Sql,Database,Codeigniter,Codeigniter 3,我使用的是CI3,我有一个搜索页面。在我的搜索页面中,我有一个名为LIKE的选项。我在搜索字符串之前使用了%value,比如,%dd11,它变成了这样 t.name喜欢的地方'�11' 我补充说 在标题中,我还在数据库配置中设置了我的字符集 这是我的表单输入字段 这是我的php代码 if (preg_match('/(LIKE).*/', $field)) { $field = preg_replace('/\s(LIKE)/', '', $field); $fiel

我使用的是CI3,我有一个搜索页面。在我的搜索页面中,我有一个名为LIKE的选项。我在搜索字符串之前使用了%value,比如,%dd11,它变成了这样

t.name喜欢的地方'�11'

我补充说 在标题中,我还在数据库配置中设置了我的字符集

这是我的表单输入字段

这是我的php代码

if (preg_match('/(LIKE).*/', $field)) {
      $field = preg_replace('/\s(LIKE)/', '', $field);
        $field =  $field.' LIKE';
        if (preg_match("/\./", $field)) {
          $where .= $field." '".$value.";
       } else {
           $where .= "t.".$field." '".$value.";
        }
}

谁能告诉我为什么它会变成这样。请帮助我在您的页面中使用
Utf8
编码后,用记事本++打开包含此字符的文件,单击
Enconding
菜单,然后选择
convert to Utf8 without boom
。保存并再次运行


您可以使用另一个文本编辑器,notepad++只是一个示例

答案可能在于,实际上这似乎是一个UTF-8和URL编码问题<代码>%dd是Ý(url编码),正在成为� 因为您的字符集不支持它。我猜您使用的是
urldecode()
,您不应该在某个地方,也没有在数据库连接器中对字符集进行排序。我在登录模块中使用的是urldecode(),而不是在此模块中。这就是我在db文件中设置字符集的方法$db['tiffinTom']['char_set']='utf8'$db['tiffinTom']['dbcollat']='utf8_general_ci';是的,我用了..我用了记事本++和升华两种语言..但不幸的是,我不擅长在逗号部分格式化文本..因此,我在问题中添加了我的代码