mysql - PHP encoding issues
I just uploaded a new site, and am having the strangest issue. I have an ajax/php search box that displays search results as the user is typing. For some reason on the live site the search results aren't always encoded properly. At times it displays correctly, but then 2 seconds later the results will look something like this:
���Ak� ��
�A<��l��&C-�F�2J�M����v��_ �]v��x���x�Q���(|ȩΜO����-x������q�ʎ�(N��(�����S�8�u��
�}¸�l���:(�j��N����C����:��u�x�?=���9se-�j�{����� r�՞b1ؑ�Ov�*[nZp"t5�(�h�� Mh���Mg��̆1z�����"�P��G�9e�dD_R�����8n%���.J^������g7��C8�hs��}�qa�$
I uploaded the site to a different web host during development and did not have this issue. I've triedutf8_encode()
but it doesn't help. Everything else on the site looks fine, it's only the search results. Any suggestions are greatly appreciated.
Answer
Solution:
You may need to add something like the following between your head tags.
Answer
Solution:
I implemented an ajax/php search box a year ago and had big problems when names had accents in them. One part of the solution involved changing the character set on the MySQL table to utf8 (it had been latin1 but I couldn't find a way to get that to work).
Then in the ajax PHP script that returned the search suggestions data, I added this line at the beginning:
It's quite likely your new hosting service has different defaults for character types in the MySQL tables and/or the webpages.