Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP/MySQL character encoding

    Hi,

    I'm trying to get UTF-16 characters into my database properly. I think I've narrowed my problem down to my connection between PHP and MySQL. This apostrophe " " is my specific problem, U+ 2019.

    I have all of my collations set to ucs2_unicode_ci (table, db connection type and field holding the values).

    I can also generate the SQL query from php, save it to a text file, then copy it into PHPMyAdmin and have it run properly.

    But still, no matter what I try my apostrophe turns into "’" when it gets to the database.

    Thank you for your help.

  • #2
    New Coder
    Join Date
    Nov 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, so I figured it out 5 minutes after posting. No reason not to share the solution.

    All I ended up having to do was use these queries:

    mysql_query("SET NAMES 'utf8'");
    mysql_query("SET CHARACTER SET 'utf8'");

    This is because the connection expects latin1 by default. Basically all these queries are doing is setting these system variables:

    character_set_connection
    character_set_client
    character_set_results
    collation_connection

    I'm assuming you can set these all in your ini file, but if your on shared space (which this particular system is for me) that makes it a bit harder.

    So there you go, hope no one got to fired up to solve this one. Hope it helps someone someday.

    Cheers,


  •  

    Posting Permissions

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