CDbException in www version of site


I am new to yii and have a site built in yii 1.1.x with 2 MSSQL dbs one local and one residing in a remote server.

I have used standard connection string in main.php as bellow




‘connectionString’ => ‘sqlsrv:Server = ‘.$dbServer_t.’; Database = ‘.$dbName_t.’’,

‘username’ => $dbUser_t,

‘password’ => $dbPass_t,

‘charset’ => ‘utf8’,



The site seems to work fine with domain name but when running as the site is showing the following error

“CDbConnection failed to open the DB connection: SQLSTATE[28000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user ‘xxxxxx’.”

I have checked separately in a test file outside yii directory with simple connection string for MSSQL and its working fine with both www and non www version.

So it appears definitely somehow the issue is with yii and somehow its restricting db connection for www version.

Can anyone please help how to fix that?

good morning,

did you try with constants?


Thanks for your reply.

But I am not clear what you exactly meant by ‘Constants’. Did you mean whether I tried by replacing the variables with hard-coded values in the connection string? Yes, I tried that but still no luck.