The connection has no charset associated

Description

This error appears when PHP cannot retrieve the character set used by the connection to MySQL. The mysqli_get_charset() function tries to fetch the data from the connexion, but the result was not usable.

Such error is probably circumstancial: the server may have gone away, or crashed, leading to no answer about charset.

Example

<?php

    $db = mysqli_init();
    $db->real_connect(localhost,user,password,test);
    var_dump($db->get_charset());

?>

Solutions

  • Check the server health.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.