Hi there everyone, and happy days 🙂
I'm trying to write an install script, and I want to be able to check the config to make sure that they have edited the db connection information.
However, the script also has the db master connection in it, and if their information is wrong, it's going to give them an error.
/Database/Mysql//
$dusername = "db_user"; //username to connect to database
$dpwd = "db_password"; //password to accecss mySQL
$dhost = "localhost"; //your db host usually localhost
$dbname = "db_name"; //db name to be accessed
$prefix = "auto_"; //prefix used in database
//Global Vars
$sitepath = "/path/to/automonial"; //sitepath without trailing backslash
$siteurl = "http://www.yoursite.com/automonial"; //siteurl without trailing backslash
/* End configuration */
$autoconn = mysql_connect("$dhost","$dusername","$dpwd") or die ("DBUser or DBPass was refused when attempting to connect to MySQL Host.");
$dbi=mysql_select_db($dbname,$autoconn) or die("Unable to make master connection to database from the config file!" . mysql_error());
I thought that I could add a variable to the install script:
$install == 1;
then place the db connection inside an if statement:
if($install == 1);{
}else{
$autoconn = mysql_connect("$dhost","$dusername","$dpwd") or die ("DBUser or DBPass was refused when attempting to connect to MySQL Host.");
$dbi=mysql_select_db($dbname,$autoconn) or die("Unable to make master connection to database from the config file!" . mysql_error());
}
but is this an ok way to do this? It seems wasteful to have the master connection inside an if/else, when it's only needed for a single install script.
Is there a better way to do this?
thanks,
json