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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TobiasHolmCommented:
Hi!

Try to replace:

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

With

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

Regards, Tobias
0
TobiasHolmCommented:
aah! Sorry, should be

'charset' => 'utf8' );

Regards, Tobias
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
semantiqueAuthor Commented:
Thanks a lot, worked great :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.