DB connection: could not find driver

Hi,

Platform

==========

Ubuntu

Xampp

my main.php is as below

‘db’=>array(

‘connectionString’ => ‘mysql:host=127.0.0.1;dbname=test’,

‘emulatePrepare’ => true,

‘username’ => ‘ankunda’,

‘password’ => ‘xxx’,

‘charset’ => ‘utf8’,

),

I have just installed Yii and test run ok. I can see file at localhost/yii/testdrive/index.php and requirements are passed too.

I was following manual to test db connection but i cannot connect to Database get this error when i issue model User,

exception ‘CDbException’ with message ‘CDbConnection failed to open the DB connection: could not find driver’ in /opt/lampp/htdocs/yii/framework/db/CDbConnection.php:255

However when i run this, no error is thrown through browser localhost/yii/testdrive/test.php

<?php

$dns="mysql:host=127.0.0.1;port=3306;dbname=test";

$user="root";

$pass="";

try{

$con = new PDO($dns, $user, $pass);

}catch (PDOException $e){

echo $e->getMessage();

}

?>

main.php available at www.content.akim.co.ug/main.txt and image from terminal at www.content.akim.co.ug/connection%20error.png

Am so confused, been at this for over 4hours.

Thanks

Hi,

your main.php looks like mine, should be correct.

Could you post, HOW do you want to access the database ? Or is the error after changing main.php ?

Scryii

Scryii, am following steps from tutorial yii-guide-1.0.12.pdf

I havent really changed anything

using yiic to try and create model User

Solved!!!

I had PHP - CLI installed as well as xampp php-5.3.0

Wrong php was being executed so used /opt/lampp/bin/php-5.3.0 protected/yiic shell and everything was fine.

How can i add to /opt/lampp/bin/php-5.3.0 environment variables