Solved

utf-8 problems

Posted on 2014-03-01
13
437 Views
Last Modified: 2014-03-02
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?
0
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 350 total points
ID: 39898210
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
 
LVL 1

Author Comment

by:joyacv2
ID: 39898513
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
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 150 total points
ID: 39898517
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 1

Author Comment

by:joyacv2
ID: 39898539
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
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39898557
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
 
LVL 1

Author Comment

by:joyacv2
ID: 39898577
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39898590
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
 
LVL 1

Author Comment

by:joyacv2
ID: 39898613
hi,

add the charset line in my ubuntu apache2.conf line and the same problem appears
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39898630
Have you restarted Apache?
0
 
LVL 1

Author Comment

by:joyacv2
ID: 39898634
hi,

i restart the server complete using sudo reboot
0
 
LVL 58

Expert Comment

by:Gary
ID: 39898651
Have you checked the encoding being used in your browser (if the problem is in the browser)
0
 
LVL 1

Author Comment

by:joyacv2
ID: 39898864
Hi,

Yes, because I am using the same browser for the MAMP and for the ubuntu server
0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39899095
I change all the documents to utf-8 and the article really explains this type of situations and problems
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question