utf-8 problems

hi, i am developing a web site using MAMP, in phpmyadmin i have a table that contains "special spanish characters", then using set utf8 for mysql there is no problem. My problem is that when i run my page in my ubuntu server, the "special spanish characters" appears incorrectly, What I can do?
LVL 1
joyacv2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
How are you displaying your data?
In a browser? Which one?

Since the characters show OK in phpmyadmin, this means the problem is in the code that displays the data on the page.

Try putting this in the <head> section of the page:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Open in new window


HTH,
Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joyacv2Author Commented:
Hi Dan,

Let me explain in more detail:

i have a code in php in page1 that generates html code combine with pure html in that page. In page one i use javascript and ajax to call a PHP page every second. In that call the ajax calls a page 2 (is pure php). The page 2 have a code that only connects to a database, makes a query and returns a echo. That echo is then received by ajax and put in a div. In that page 2 i use a code that sets the query to utf8 and all works perfect. So my page works perfect in all aspects. The problem comes when I move the website from my local MAMP to my ubuntu web server. In my ubuntu something happens that the "special spanish characters" look strange. Why is happening in ubuntu and not in my MAMP enviroment?
0
Ray PaseurCommented:
This is an increasingly common issue.  Please read this article and then post back if you still have questions about character set collisions.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

joyacv2Author Commented:
Hi Ray,

This is a espectacular article, do you think that there is some configuration in my server that is different from my MAMP?
0
Dan CraciunIT ConsultantCommented:
Yup. The default charset.
Add this to httpd.conf in your MAMP AddDefaultCharset UTF-8
This will tell Apache to serve all pages as UTF-8
0
joyacv2Author Commented:
hi

in my mamp all works well, it is in my ubuntu that i have the problems. This lines is exactly that you mention?
0
Ray PaseurCommented:
You may find that it's needed in your HTML documents' meta charset tag, as well as in the data base connections.  You may also want to be careful about the PHP code for things like strlen() and substr() because the UTF-8 characters for the accented western letters are more than one byte long.
0
joyacv2Author Commented:
hi,

add the charset line in my ubuntu apache2.conf line and the same problem appears
0
Dan CraciunIT ConsultantCommented:
Have you restarted Apache?
0
joyacv2Author Commented:
hi,

i restart the server complete using sudo reboot
0
GaryCommented:
Have you checked the encoding being used in your browser (if the problem is in the browser)
0
joyacv2Author Commented:
Hi,

Yes, because I am using the same browser for the MAMP and for the ubuntu server
0
joyacv2Author Commented:
I change all the documents to utf-8 and the article really explains this type of situations and problems
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.