MYSQL, PHP, ZEND: SQLSTATE[42000] [1115] Unknown character set: 'utf-8'

Hi there,

I'm getting the following exception

"SQLSTATE[42000] [1115] Unknown character set: 'utf-8'"

with the attached minimal code.

We are using: "mysqld  Ver 5.0.67-0ubuntu6 for debian-linux-gnu on i486 ((Ubuntu))" which is the latest in the apt packages.

Does anyone know how to fix this?

Thank you in advance.
<?php
require_once 'Zend/Db.php';

$host = '';
$username ='';
$password = '';
$name = '';
$table = '';

     $pdoParams = array (
          PDO::ATTR_PERSISTENT => true,
          PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
          PDO::ATTR_EMULATE_PREPARES => true,
          PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8' );

     $params = array (
          'host' => $host,
          'username' => $username,
          'password' => $password,
          'dbname' => $name,
          'driver_options' => $pdoParams,
          'charset' => 'utf-8' );
var_dump($params);

$db = Zend_Db::factory ( "Pdo_Mysql", $params );
try{
  $result = $db->fetchAll("Select * from $table");
  var_dump($result);
}catch(Exception $ex){
  print $ex->getMessage();
}
?>

Open in new window

semantiqueAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TobiasHolmConnect With a Mentor Commented:
aah! Sorry, should be

'charset' => 'utf8' );

Regards, Tobias
0
 
TobiasHolmCommented:
Hi!

Try to replace:

'charset' => 'utf-8' );

With

'charset' => 'UTF-8' );

Regards, Tobias
0
 
semantiqueAuthor Commented:
Thanks a lot, worked great :)
0
All Courses

From novice to tech pro — start learning today.