Jump to content

PHP MYSQL Char set issue - � appears


cjkeane

Recommended Posts

Hi everyone,

 

I'm sure you all have come across this issue before, and I have read a lot of posts regarding it, but I have only been able to partially resolve my issue.

 

I have a mysql database and I'm using php to retrieve the data. I imported data from a csv into mysql and all entries which have accented characters have been mangled and appear as: �. When text is entered with accented characters and saved using php into the mysql db, the characters retain the accented characters.

 

I'm wondering if anyone would know how to write code to check if a string e.g. (first_name) is utf-8, if not then utf-8 decode it? I believe that would solve my issue. Or if anyone else has any suggestions which might help, I'd appreciate it.

 

Also, sometimes I notice a � will appear between lines of text when it should have been a line break.

 

If anyone could suggest a solution to those issues, I'd appreaciate it.

 

Thanks.

Link to comment
Share on other sites

the db collation is: utf8_unicode_ci

 

on each php page I have the following:

 

<?php

mysql_query("SET NAMES 'utf-8'");

?>

 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

As I said, any new data saved via php into the mysql db retains the accented characters. It's just retrieving data (for e.g. first_name) which was imported from a csv into the mysql db which isn't displaying the accented characters correctly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.