简体   繁体   中英

Wild card in a search string become special character

I am using CI3 and i have a search page. In my search page, I have a option called LIKE. I used % value before my search string, like, %dd11, which is become something like this

WHERE t.name LIKE ' 11'

I have added in the header and i also set up my charset in database config.

here is my form input field

and here is my php code

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.";
        }
}

can anyone tell me why its become encoded like this. please help me

After using Utf8 encoding in your page, open the file containing this character with notepad++ and click on Enconding menu, then choose convert to utf8 without boom . Save and run again.

You can use another text editor, notepad++ is just an example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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