Query problem - Accentuation

-1

My MySQL database is in UTF-8, pages in UTF-8, so far everything works. No problem with charset .

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

I type "A" and it returns companies that have this initial letter + companies that start with "Ó", because in the bank it turns the "Ó" into "Ã". In the above example it pulls the "Optics" you have registered.

I honestly do not know how to solve. I tried changing the parameters in the search, but to no avail.

Maybe you force something like case-sensitive to accents (if at all possible).

Would anyone have any idea how to solve this? Preferably without changing DB.

OBS: Programming in PHP.

    
asked by anonymous 14.07.2015 / 22:58

3 answers

1

1st Alternative:

Open the file .php in notepad ++ and go to the formatar menu button 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 you are rendering is not in the utf-8 standard, so add this line to it:

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

3rd Alternative:

Add this to the beginning of your .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 be as below:

default_charset = "UTF-8"

6th Alternative:

If you do not have access to the file php.ini add the following line at the top of the document .php :

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

7th Alternative:

ini_set('mssql.charset', 'UTF-8');
    
15.07.2015 / 00:14
0

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

  • Add to the top of the page PHP header ('Content-type: text / html; charset = UTF-8');
  • Place the mysql-> query ('SET NAMES utf8') command after connecting to MySql;
  • Use the Tag Tag < meta-content="Content-Type" content="text / html; charset = utf-8" / >
  • Attempt to change the language of the site to another language < meta http-equiv="Content-language" content="en-us" / >
  • See if it works.

        
    14.07.2015 / 23:11
    0

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

    14.07.2015 / 23:17