Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2007
    Posts
    212

    Unanswered: Character encoding problem?

    Hi,

    I have a table in mysql with its character encoding as
    Code:
    COLLATE='utf8_general_ci'
    .

    I have a web page to display this data using utf8 encoding as well:

    Code:
    header('Content-Type: text/html; charset=utf-8')
    The orginal data is submited to the database via a web form.

    However when I display this data on a webpage I still end up with strange characters?

    Example:
    Data stored in the database:

    HTML Code:
    Open University (Business school) –
    Data as it appears whne displayed on a web page with utf8 encoding:

    HTML Code:
    Open University (Business school) –(some square boxes appear here)

    Is this because its ended up as funny characters inside the database in the first place? If so how does one amend the web form so that correct characters go inside the database. Or is this due to something else all together?
    Last edited by ozzii; 06-17-11 at 11:17. Reason: error

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    have you examined the data inside the db using another query mechanism
    eg
    PHPMyAdmin
    MySQL Workbench
    Heidi SQL
    ..or even the MySQL command line
    ..to prove where the problem is, ie is it the data and?or its storage mechanism or is it the front end. granted if its a PHP problem then PHPMyAdmin may not be definitive proof
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2007
    Posts
    212
    I've used Heidi sql to view the data inside the database and its being stored as


    Code:
    Open University (Business school) –
    Does this mean that even if the database collation is utf8 it wont necesserily convert non utf8 characters to utf8?

    I've stumbled upon the following:

    UTF8, PHP and MySQL – Rob Allen's DevNotes

    but since am using php 5.3 I cant even change the PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8 since it wont work!

    Bugs after bugs after bugs!

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by ozzii View Post
    Bugs after bugs after bugs!
    that age old adage:- y'get what y'pay for comes to mind

    its one of the bugbears I have with the open source movement that many bugs seems to live for ever. that doesn't mean commercial software is bug free, but at least (usually) you know that there will be a resolution.

    did you try inserting the utf data directly into the db, avoiding PHP altogether. My guess is its a PHP issue, although there may be MySQL problems aswell
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2007
    Posts
    212
    does anyone know what these characters are if decoded:

    Code:
    –
    Is there any way I can decode these characters to what they should be so that I can do some tests?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •