user1384817
user1384817

Reputation: 13

php mysql codeigniter character encoding

Iam using codeIgniter and having the following settings but still my webpage is displaying "?" in case of special characters.

Database - UTF-8 encoding Table - UTF-8 column -UTF-8 in the html file I have the following line added

<? header("Content-Type: text/html; charset=UTF-8"); ?>

37 degrees centigrade is displayed as "maintained at 37�C"

and other special characters are also wrongly displayed.

Upvotes: 0

Views: 402

Answers (3)

Sorav Garg
Sorav Garg

Reputation: 1067

Please try with utf8_general_ci collation.

$db['default']['dbcollat'] = "utf8_general_ci";

If still your problem is not resolved, then set column collation as utf8_general_ci in your database table.

This will work.

Thanks

Upvotes: 0

user1384817
user1384817

Reputation: 13

Adding

<?php header('Content-type: text/html; charset=iso-8859-1'); ?>

to my html header worked for me!!!!

Upvotes: 0

Abdulla Nilam
Abdulla Nilam

Reputation: 38652

Set this

In config.php

$config['charset'] = "UTF-8";

In database connection

$db['default']['char_set'] = "utf8"; 
$db['default']['dbcollat'] = "utf8_unicode_ci";

In Header of your file

echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
// Generates:  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

Upvotes: 1

Related Questions