1

I get ready with DataTables for make a nice table with JQuery and html.

But when query to my db it show me values like this in this characters cases (almost).

(Spanish letters) áéíóúÑ 

Any suggestions.

ADDED DATATABLE CODE USED:

var table = $('#example').DataTable({
  // Localization
  language : {
    emptyTable     : 'Nada para mostrar.',
    zeroRecords    : 'Nada coincide.',
    thousands      : '.',
    processing     : 'Cargando informacion...',
    loadingRecords : 'Cargando Informacion...',
    info           : ' _PAGE_ / _PAGES_',
    infoEmpty      : ' 0 / 0',
    infoFiltered   : '( _MAX_ )',
    infoPostFix    : '',
    lengthMenu     : 'Mostrando _MENU_',
    search         : 'Filtrar:',
    paginate       : {
      first    : 'Primero',
      last     : 'Ultimo',
      next     : 'Siguiente',
      previous : 'Previo'
    }
  }
});jquery

1 Answers1

0

The solution for this problem radicate on the PDO call.

I wrongly use for mistake two differents calls, one of the not using the utf8 correct configuration on the call like this

try{
    $pdo = new PDO("mysql:host=".DBHost.";dbname=".DBName."", DBUser, DBPassword);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    } catch(PDOException $e){

      die("ERROR: Could not connect. " . $e->getMessage());

   }

And finally when add the CORRECT utf-8 configuration all characters showing good.

 try{
    $pdo = new PDO('mysql:dbname=' . $this->DBName . ';host=' . $this->Host . ';port=' . $this->DBPort . ';charset=utf8', 
            $this->DBUser, 
            $this->DBPassword,
            array(
                //For PHP 5.3.6 or lower
                PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'",
                PDO::ATTR_EMULATE_PREPARES => false,
                //
                //PDO::ATTR_PERSISTENT => true,

                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
            )
        );

    } catch(PDOException $e){

      die("ERROR: Could not connect. " . $e->getMessage());

   }

The last code solved the problem. Thanks!