I'm using Dreamweaver to publish my website to the web server. I have a php file called init.php that I include in my pages containing information relevant to connecting to my DB. The information is different depending on whether I'm running on my local test server or on the remote server. I would like to have a remote init.php and a local init.php and whenever I "put" my site from dreamweaver, I don't want the remote copy of init.php to be overwritten. How do I do this? Is there a special setting in dreamweaver?
A:
I use this all the time it is what you need, just one file but in your settings use this:
if($_SERVER['HTTP_HOST'] == 'localhost') //if url for test server is http://localhost/your_file.php
{
//Dev
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "password";
$db['default']['database'] = "database";
}
else
{
//Live
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "converse";
$db['default']['password'] = "password";
$db['default']['database'] = "public_prod";
}
Just change the if statement to match what your host is on testing server and that is it.
I have used this forever works great just a simple wrapper on your connect information. pay no attention to inside the if and else it is just codeigniter's database variables but the core if statement is what does it.
BrandonS
2010-07-31 01:20:27
ah thanks, that should work fine!
JPC
2010-07-31 01:50:40
not a problem, I'm glad I could help.
BrandonS
2010-07-31 02:29:41