Codeigniter 3.1.9 - Database connection

Asked

Viewed 297 times

1

I am developing a web application using version 3.1.9 of Codeigniter, but I’m having difficulties connecting to the database.

Follows configuration:

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => 'mysql:host=localhost; port=3306; dbname=tarifador; charset=utf8',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '******',
    'database' => 'tarifador',
    'dbdriver' => 'pdo',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Error presented:

A PHP Error was encountered
Severity: Warning
Message: PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
Filename: pdo/pdo_driver.php
Line Number: 136
Backtrace:
File: C:\xampp\htdocs\index.php
Line: 315
Function: require_once
A Database Error Occurred
SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
Filename: C:/xampp/htdocs/system/database/drivers/pdo/pdo_driver.php
Line Number: 142

In the database Schema is already configured as UTF8 e UT8_general_ci.

I’ve also tried using the driver mysqli.

Additional details: PHP version: 5.6.37 Mysql Version: 8.0.12

Grateful to those who can help

  • There is this case of the OS. If it works, consider translating it to Sopt to help more colleagues. https://stackoverflow.com/questions/43437490/pdo-construct-server-sent-charset-255-unknown-to-the-client-please-rep

  • I have tried this solution, but the problem remains.

1 answer

0

From what I understand in this Issue of PHP Mysql 8 has as default charset the utf8mb4 and according to the last comment these problems were fixed in PHP 7.

[2018-05-02 17:37 UTC] macleo at outlook dot com

Should be Fixed as of 7.0.19, 7.1.5, and 7.2.0. Anyone confirm? - yes

Since PHP 5.x does not recognize this charset, the most likely solution is that your tables should be changed to the charset utf8.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.