0

I'm 100% this is user error on my part.

I'm using the focuslab master config set up to run locally, staging and live. The site works correctly on live and locally but staging I keep getting a database error.

Unable to connect to your database server using the provided settings.

Filename: core/EE_Config.php

Line Number: 207

After looking at this thread I added exit('here'); to config.stage.php but nothing happened. I've tested the database credentials in another script and the connections are working there. Am quite lost.

my config.env.php file has the following:

switch (strtolower($_SERVER['HTTP_HOST'])) {
    case 'domain.ca' :
        define('ENV', 'prod');
        define('ENV_FULL', 'Production');
        define('ENV_DEBUG', FALSE);
    break;

    case 'domaindev.com' :
        define('ENV', 'stage');
        define('ENV_FULL', 'Staging');
        define('ENV_DEBUG', FALSE);
    break;

    case 'localdomain.dev' :
        define('ENV', 'local');
        define('ENV_FULL', 'Local');
        define('ENV_DEBUG', TRUE);
    break;

    default :
        define('ENV', 'local');
        define('ENV_FULL', 'Local');
        define('ENV_DEBUG', TRUE);
    break;

The live site is at domain.com and staging is at subdomain.mysite.com

I can see the working site locally and on live (just deployed the master branch to live and to staging), but getting the database error on staging.

Please advise

  • I may just misunderstand your post but you have changed 'domaindev.com' to 'staging.mysite.com' haven't you? – foamcow Mar 22 '14 at 13:38
2

I may just misunderstand your post but you have changed 'domaindev.com' to 'staging.mysite.com' haven't you?

Also try putting the staging db connection info in for the default/local environment (on your staging server) to see if it's just falling through to the default. Which would imply the domain isn't properly set.

| improve this answer | |
  • When I change domaindev.com to sub.domaindev.com I get a white screen of death. As it is, now I at least see that I'm getting a database failure. – CreateSean Mar 22 '14 at 14:32
  • So I followed your suggestion and changed the local environment (on the server) to use the staging db info and it works. – CreateSean Mar 22 '14 at 14:36
  • So it's tripping over the domain or, more likely, the staging.env file has a syntax error in it. That is failing while being included into the main config and is why you don't see an error. if you can't see the syntax error then try putting the contents of the staging file into another PHP file and loading it directly. – foamcow Mar 22 '14 at 14:44
3
  1. Make sure the staging domain is correct in config.env.php
  2. Make sure the staging config is in fact loaded (put a die("hello); at the top of your config.staging.php)
  3. Verify that your site says "hello" on staging, which means it is actually loading the staging config.
  4. Edit both index.php and admin.php and set $debug=1; in both.
  5. Remove the die() you put in config.staging.php in step 2)
  6. Load the website again, you should now get a PHP error (most likely in your config.staging.php file)

Fix the PHP error and you should be good to go :-)

(oh and you might want to set $debug=0; again in index/admin.php once everything is working)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.