1

I run a centos7 server with Cpanel. PHP Version 7.2.26

Im trying to connect to CDbConnection. All i get is error:

Fatal error: Uncaught CDbException: CDbConnection failed to open the DB connection. in yiiframework/db/CDbConnection.php:405 Stack trace: 
#0 /yiiframework/db/CDbConnection.php(347): CDbConnection->open() 
#1 /yiiframework/db/CDbConnection.php(325): CDbConnection->setActive(true) 
#2 /yiiframework/base/CModule.php(394): CDbConnection->init() 
#3 /yiiframework/base/CModule.php(103): CModule->getComponent('db') 
#4 /protected/components/FunctionsV3.php(6210): CModule->__get('db') 
#5 /protected/controllers/StoreController.php(149): FunctionsV3::checkIfTableExist('option') 
#6 /yiiframework/web/CWebApplication.php(281): StoreController->init() 
#7 /yiiframework/web/CWebApplication.php(141): CWebApplication->runController('store/index') 
#8 /yiiframework/base/CApplication.php(185): CWebApplication- in /yiiframework/db/CDbConnection.php on line 405

I have tryed everything, the settings is ok. This is my db connect

'db'=>array(            
            'class'            => 'CDbConnection',
            'connectionString' => 'mysql:host=xxxxxxxxxxxxx;port=3306;dbname=xxxxxxxxx',
            'emulatePrepare'   => true,
            'username'         => 'xxxxxxxxxx',
            'password'         => 'xxxxxxxxxxxxxxxxxx',
            'charset'          => 'utf8',
            'tablePrefix'      => 'mt_',
        ),
5
  • This is a stack trace, not an actual error description. It’s used to determine the route taken within code to get where you are now (hence, a stack) Commented Jan 27, 2020 at 20:04
  • what can i do..Nothing works Commented Jan 27, 2020 at 20:07
  • @Niklas ok, mind to tell us where do you exactly use this db connect? I was looking a bit into the Yii documentation, and I've seen that you actually put this into the file called db.php. Check here -> yiiframework.com/doc/guide/2.0/en/… . Also if you use CPanel, there should be an option pane for PHP settings -> manage.accuwebhosting.com/knowledgebase/2331/…. Make sure you have your pdo_mysql enabled, hence it won't work. Commented Jan 27, 2020 at 20:22
  • I have a file called main.php where everything is...i have pdo_mysql enabled.. Still dont work. Commented Jan 27, 2020 at 22:44
  • and i have this setting installed on the server, PHP 7.2, MySQL client, PDO, CURL Open, Session enabled, Mail functions enabled, Mod_Rewrite Module Enabled Commented Jan 28, 2020 at 20:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.