7

Good day,

I am using Codeigniter to develop my webapp. PHP version on the server is 5.6.22 and Mysql version of the db is 5.6.27. In codeigniter's database.php when I change the charset to "utf8mb4" from "utf8", I get the following message .(image attached)

Unable to set client connection character set: utf8mb4

enter image description here

UPDATE I can run the codeigniter app on another server that has the same php version and the same mysql version. So it must be something pertaining to httpd.conf or php.ini, maybe?

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Waris Ali
  • 522
  • 3
  • 14

2 Answers2

6

In database.php

Set char_set to utf8mb4 and dbcollat to utf8mb4_unicode_ci or utf8_general_ci


I tested this with my Codeigniter 3.0

$db['default'] = array(
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8mb4',
    'dbcollat' => 'utf8mb4_unicode_ci',

);

And in controller I add this

$CI = &get_instance();
$CI->load->database();
echo $CI->db->char_set;
echo "<br>";
echo $CI->db->dbcollat;

Output

utf8mb4
utf8mb4_unicode_ci

Read this

  1. Using utf8mb4 with php and mysql
Community
  • 1
  • 1
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

I was able to remove the bug by removing my php installation and installing the httpd and php again from scratch.

Waris Ali
  • 522
  • 3
  • 14