Query problem - Accentuation

Asked

Viewed 141 times

-1

My Mysql database is in UTF-8, pages in UTF-8, so far all working. No problem with charset.

The problem is when I research something (company) in the search, for example:

I type "A" and it returns the companies that have this initial letter + the companies that start with "O", because in the bank he transforms the "O" into "A"". In the example cited he pulls the "Optics" that has registered.

I honestly do not know how to solve. I tried to change the parameters in the search, but without success.

Maybe force yourself on something like case-sensitive for accents (if possible).

Would anyone have any idea how to fix this? Preferably without changing the comic.

NOTE: Programming in PHP.

3 answers

1

1st Alternative:

Open the file .php on Notepad++ and go to menu button formatar and select the option: Codificação em UTF-8 (sem BOM), it is possible that the PHP source file is not utf-8.

2nd Alternative:

The page .html which is rendering not in the standard utf-8, so add this line to it:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

3rd Alternative:

Add this at the beginning of your file .php

header('Content-Type: text/html; charset=utf-8');

4th Alternative:

Add the following line to the file .htaccess

AddDefaultCharset UTF-8

5th alternative:

Edit the following line in the file php.ini to stand as below:

default_charset = "UTF-8"

6th Alternative:

If you don’t have access to the file php.ini add the next line at the top of the document .php:

ini_set('default_charset', 'UTF-8');

7th Alternative:

ini_set('mssql.charset', 'UTF-8');
  • Ricardo, all possibilities tested, but without success. No change.

  • @Marcogarcia will see other alternatives

  • See which collar of your bank

  • Use the following command and put the results here: use banco_de_data; show variables like "character_set_database"; show variables like "collation_database";

  • character_set_database > utf8

  • Example of my query: (e.nomefantasia LIKE 'A%') ... and at the end it returns "Ã"TICA CAROL", for example. I’ve tried to insert COLLATION straight into the line, but it came to nothing.

  • When you do search by mysql console of this problem?

  • That’s right. Both the console and PHP have the same problem

  • The problem then must be in the bank

  • Any suggestions?

  • @Marcogarcia I am thinking

Show 6 more comments

0

If it is turning your input into the database query, then there is a charset problem yes. One way to force your data entry into your query is by using: html_entity_decode($data), or do better, open it in the notepad and save as ASCII, then in your IDE convert it to UTF-8.

  • Ivan, tested but unsuccessfully.

  • Marco, you can send the files where the problem is occurring to us to help you.

  • Yes, I do, Ivan. How do you run the OS? Now that I’ve started using...

  • zip and send me the link, like: https://www.wetransfer.com/, Dropbox, etc...

0

You can try to make these changes and check if they will work.

  1. Add at the beginning of the PHP header page('Content-type: text/html; charset=UTF-8');
  2. Place after connection to Mysql the command $mysqli->query('SET NAMES utf8');
  3. Use meta tag < meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. Try to change the site language to another language < meta http-equiv="Content-language" content="en" />

See if it works.

  • Roberto, tested but without success.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.