I'm trying to push a site live today and am running into a problem I'm having trouble solving. I have a staging site which is a subdomain on the live server and everything works fine there but when I try to load the live site I get the following error (strange characters and all):
An exception has been thrown during the rendering of a template ("Craft can't connect to the database with the credentials in craft/config/db.php.") in "_includes/_main_nav" at line 19.
The only difference between the two config files is the database name in db.php and the siteUrl and fileSystemPath in general.php. I do have a multi-environment config based on the one at straughtupcraft.com but I don't see any other difference between my live and staging environments other then what is already noted above.
Anyone run across this problem yet? Solutions?
UPDATE:
index.php:
<?php
//die('hey');
// Path to your craft/ folder
$craftPath = '../craft';
// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';
if (!is_file($path))
{
exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}
require_once $path;
// Check the SERVER_NAME variable ourselves
switch ($_SERVER['SERVER_NAME'])
{
// If the SERVER_NAME variable matches our case,
// assign the CRAFT_ENVIRONMENT variable a keyword
// that identifies this environment that we can
// use in our multi-environment config
case 'site.com' :
define('CRAFT_ENVIRONMENT', 'live');
break;
case 'staging.site.com' :
define('CRAFT_ENVIRONMENT', 'staging');
break;
default :
define('CRAFT_ENVIRONMENT', 'dev');
break;
}
general.php
return array(
'*' => array(
'cpTrigger' => 'site_admin',
'omitScriptNameInUrls' => true,
'slugWordSeparator' => "_",
),
'live' => array(
'environmentVariables' => array(
'siteUrl' => 'http://site.com',
'fileSystemPath' => '/path/to/domains/site.com/html'
)
),
'staging' => array(
'devMode' => true,
'environmentVariables' => array(
'siteUrl' => 'http://staging.site.com',
'fileSystemPath' => '/path/to/domains/staging.site.com/html'
)
),
'dev' => array(
'devMode' => true,
'environmentVariables' => array(
'siteUrl' => 'http://site.dev',
'fileSystemPath' => '/users/stubear/sites/site/dev/html'
)
),
);
db.php
return array(
'*' => array(
'tablePrefix' => 'craft',
),
'live' => array(
'server' => 'server',
'user' => 'username',
'password' => '********',
'database' => 'craft_live_db',
),
'staging' => array(
'server' => 'server',
'user' => 'username',
'password' => '********',
'database' => 'craft_staging_db',
),
'dev' => array(
'server' => 'localhost',
'user' => 'root',
'password' => 'root',
'database' => 'site-dev',
),
);