[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

php / mysql / html5 and charset...

Posted on 2011-05-05
5
Medium Priority
?
529 Views
Last Modified: 2012-08-13
ok.  I give in.

I have tried for ages, but can't solve this, I know there is going to be a simple solution - don't let me down experts.

I build content managed websites using php and mysql.  I also use the webassist HTMLEditor pluging as my HTML editor of choice.

Recently I upgraded to HTMLEditor 3 and roughly at the same time, started using HTML5 (loving the curvy corners and wonky boxes), but I'm having an impossible issue with my charset and the content managed data...

The text that I edit/create using the HTML editor gives me <?> (black diamond with question mark) characters instead of £ (pound sugns) when it displays.

I am using the <meta charset=utf-8 /> as my charset definition. (tried all sorts of variations)

Here's the issue.  If I type '£' into my document source, it renders as a £, but any £ entered via the HTML editor render as <?>.  Using phpmyadmin to check what's being saved shows me a £.

I can't see any encoding settings on the webassist htmleditor, on file, it looks fine, entering £ into the source file works fine, but the stuff stored in MySQL, pulled in via PHP and 'echo'ed doesn't work...

Please help, someone.  Been going on too long, so max points for a quick solution.

Got a client meeting in 10 hours, can anyone resolve?




0
Comment
Question by:CrisThompsonUK
  • 3
5 Comments
 

Author Comment

by:CrisThompsonUK
ID: 35702866
p.s.
going to bed now, so won't be able to post any more replies for 8 hours or so...
0
 
LVL 9

Expert Comment

by:Erdinç Güngör Çorbacı
ID: 35703274
Are your mysql db and table and field's encoding utf8 and collations are utf8_general if not try converting them.
You can also solve this with iconv from php side.
look at sample taken from php.net below

 
<?php
$text = "This is the Euro symbol '€'.";

echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;

?>

Open in new window


You can find details here ; http://php.net/manual/en/function.iconv.php

Good luck
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 2000 total points
ID: 35704100
Try to put this
    mysql_query("SET NAMES 'utf8'");
just after you connect to the database. Maybe I misunderstood something, but is the pound sign visible in the database or it is put in the database as a black diamond ? Check your file charset encoding also.
0
 

Author Closing Comment

by:CrisThompsonUK
ID: 35704844
lovely.
0
 

Author Comment

by:CrisThompsonUK
ID: 35753086
Just to keep this answer complete, this fix worked for one of my sites, but not for another until I changed the MySQL data type from BLOG to TEXT...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 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