Problem inserting special character in Mysql

Asked

Viewed 42 times

0

When I insert some information in Mysql through the form in my system is saved all wrong in the BD, the characters ç, `Uga everything, but insert manually in the right phpmyadmin. In HTML I put the UTF-8 meta charset tag and in php ini UTF-8 charset

To read the BD’s documents it’s all right, not the problem. Just to insert.

Technical Solutions

The following is saved

Soluã§Ãµes Tà cnica

Thanks for the help

1 answer

0

Try to insert this code, at the end, into your file that allows validating the database:
... resto do código ... mysql_query("SET NAMES 'utf8'"); mysql_query('SET character_set_connection=utf8'); mysql_query('SET charecter_set_client=utf8'); mysql_query('SET charecter_set_results=utf8');

If you are using mysqli would be:

mysqli_query($conn,"SET NAMES 'utf8'");

...

Also try in all your files .php insert
header ('Content-Type: text/html; charset=UTF-8');

  • Thanks for the help, when I put this code gave error in the page. I put the Header (No error, but nothing changed :'( )

  • The code you entered at the end of the page to validate the database right? Strange always worked on me, what mistake appears?

  • is it this way ? <? php&#xA;&#xA;$conexao = mysqli_connect('localhost', 'root', '', 'pedidos');&#xA;&#xA;mysqli_query("SET NAMES 'utf8'");&#xA;mysqli_query('SET character_set_connection=utf8');&#xA;mysqli_query('SET charecter_set_client=utf8');&#xA;mysqli_query('SET charecter_set_results=utf8');&#xA;&#xA;?>

  • Where have you mysqli_query you forgot to put $connection, in this case it stays like this in your code mysqli_query($conexao,"SET NAMES 'utf8'); mysqli_query($conexao,'SET character_set_connection=utf8'); etc.

Browser other questions tagged

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