CodeIgniter Forums
Unable to set client connection character set: utf8mb4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Unable to set client connection character set: utf8mb4 (/showthread.php?tid=65707)



Unable to set client connection character set: utf8mb4 - MasoodRehman - 07-14-2016

I am creating a web app with ios developer, ios developer send text message with emoji and i store it on server db.
The emoji is not storing in table column someone told me change the column collation to utf8mb4_unicode_ci from utf8_unicode_ci and also change the application/config/database.php char_set to utf8mb4 and dbcollat to utf8mb4_unicode_ci but it gives me error on server on localhost it is working.

Please help thanks.


RE: Unable to set client connection character set: utf8mb4 - InsiteFX - 07-14-2016

Is the live server running the same version of MySQL that you are running on your localhost?


RE: Unable to set client connection character set: utf8mb4 - MasoodRehman - 07-15-2016

(07-14-2016, 10:52 AM)InsiteFX Wrote: Is the live server running the same version of MySQL that you are running on your localhost?

Yes, actually i have two environment on server dev and live, both using same MySQL versions on dev utf8mb4 working but on live don't work.
And when i access the site on live server it show me the error [[/url][url=http://i.stack.imgur.com/nkM0p.png]snap shot], i am wonder why this is happening unable to find the main reason.


RE: Unable to set client connection character set: utf8mb4 - InsiteFX - 07-15-2016

Here is a stand alone script to test if the charset is being set or not will return the error if not set.

PHP Code:
<?php

// Set these for your server
define('db_user''');        // The database users name
define('db_password''');    // The database password
define('db_database''');    // The database name

$conn_id mysqli_connect('localhost'db_userdb_passworddb_database);

// check connection
if (mysqli_connect_errno()) {
 
   printf("Connect failed: %s\n"mysqli_connect_error());
 
   exit();
}

printf("Initial character set: %s\n"mysqli_character_set_name($conn_id));

// change character set to utf8mb4
if ( ! mysqli_set_charset($conn_id"utf8mb4"))
{
 
   printf("Error loading character set utf8mb4: %s\n"mysqli_error($conn_id));
 
   exit();
}
else
{
 
   printf("Current character set: %s\n"mysqli_character_set_name($conn_id));
}

mysqli_close($conn_id);

?>