0

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

surma
  • 97
  • 1
  • 9
  • 2
    The answer probably lies [here](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through/279279) – CD001 Jun 05 '18 at 09:15
  • Actually this seems to be both a UTF-8 and URL encoding issue... `%dd` is **Ý** (url encoded) which is becoming � as it's not supported in your charset. I'm guessing you're using `urldecode()` somewhere you shouldn't be and haven't sorted the charset in the database connector maybe. – CD001 Jun 05 '18 at 09:35
  • I am using urldecode() in my login module, not in this module. And this is how I set up char set in db file; $db['tiffinTom']['char_set'] = 'utf8'; $db['tiffinTom']['dbcollat'] = 'utf8_general_ci'; – surma Jun 05 '18 at 11:32

1 Answers1

0

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

Bellash
  • 7,560
  • 6
  • 53
  • 86