function isValidDBServer() {
/*--------------------------------------------------------------------------------------------------------------------
This will check if $dbBrandName is the same as your database server connection to the webserver. The check
will simply be done by making a simple db connection; if the connection fails then the db server name is
inconsistent with the existing db, or there is no detectable db server instance. Otherwise, disconnect and
return true
Currently will work with the following dbs:
1) mySQL
2) PostgreSQL
3) mSQL
4) SQL Server
5) Sybase
6) Oracle
---------------------------------------------------------------------------------------------------------------------*/
global $dbBrandName,$dbHost,$dbPort,$dbUser,$dbPwd,$dbDefaultName;
switch (strtolower($this->dbBrandName)) {
case 'oracle':
$resource = ora_login("$dbUser@$dbHost", $dbPwd);
if (!$resource) return false;
@ora_logoff($resource);
break;
default:
eval("\$result = " . strtolower($this->dbBrandName) . "_connect('$dbHost', '$dbUser', '$dbPwd');");
if (!$result) return false;
eval('@' . strtolower($this->dbBrandName) . "_close('\$result');");
break;
}
return true;
}
Whenever I run this function, which checks to see what type of db server prog you're running (Oracle, SQL Server, mySQL, etc.), if the value of $dbBrandName is 'mySQL', everything is just fine, provided your webserver is connected to a mySQL database server instance. If not, it rightly returns false. However, I tried to test this code out by changing the value of $dbBrandName to 'mssql' for SQL Server and I received the following error:
Fatal error: Call to undefined function: mssql_connect() in /var/www/html/development/phillip/mu-spin/include/db_action.inc(71) : eval()'d code on line 1
This makes no sense because mssql_connect() is a basic PHP core function (based upon reading the manual at http://us4.php.net/manual/en/function.mssql-connect.php)
Could someone give me a better idea of the behavioral problems I'm plagued with? My goal is to create a boolean function that determines that if you are trying to backup a database or restore a database and you're not referencing the right database, you can't do anything.
Help!
Thanx
Phil