首页 > 解决方案 > Got error 'invalid UTF-8 string at offset 1' from regexp

问题描述

I need help, I have tried to find the solution but until now all I have found is stuff related to regex but I think the problem might be in another place.

I have a project locally (Windows 10 --> Xampp Latest version [Apache & Mysql], I use CodeIgniter as Framework, I developed a function which searches in my database using REGEXP (I use query builder)

It works fine and everything. Here I searched for saltarín <-- Note the accent on the letter i enter image description here

So now that it works I have decided to update the online website but as soon as I was testing the online project I noticed an error jumps when I search something with accented characters or in this case the letter ñ which also works locally.

enter image description here I checked my database configurations, in database.php I have dbcollat set to utf8_spanish_ci and my online database and tables are set to utf8_spanish_ci too, I think this must be a server configuration but I don't have an idea of what it really could be

In case you need it this is the piece of code which uses regexp

$this->db->where("lower(secret_colum_name) REGEXP", $this->secret_hehe);

Thanks a lot for your time, I really appreciate your help.

EDIT: I forgot to mention I'm using hostinger to host my website

标签: regexdatabasecodeigniterquery-builder

解决方案


又是我。就像我怀疑是服务器的问题一样,经过几个小时的研究,我发现我的服务器没有相同的扩展名和配置,你可以使用php -m命令找出你的本地扩展名,然后你就可以启用它们在您的远程服务器上,在我的情况下,我必须通过 c-panel 完成,但您的情况可能会有所不同。

在此处输入图像描述

我还在远程服务器中更改了我的 php 版本,我不太确定接下来的事情,但它可能会有所帮助。

我在我的模型中定义了一个二传手,它做了接下来的事情

$this->my_var = strtolower($my_var);

我删除strtolower了,在前面提到的所有步骤之后,我重新加载了我的网站,现在它可以工作了

在此处输入图像描述


推荐阅读