Connect to MYSQL <-----// $DATABASE_HOST = '127.0.0.1' ; $DATABASE_USER = 'root'; $DATABASE_PASS = ''; $DATABASE_NAME = 'NGC-Tico'; $user = "NGCTico" ; $Pwd = " " ; try { $dsn = new PDO("mysql:host=$DATABASE_HOST;dbname=$DATABASE_NAME",$DATABASE_USER, $DATABASE_PASS); } catch(PDOException $e) { echo "MYSQL Connection Failed: ". $e->getMessage(); } //---> For Development <---// //$stmt=$dsn->prepare('Select actinfo, host, dbname from accounts // where type="D" and username = ?'); //---> For Production <---// $stmt=$dsn->prepare('Select actinfo, host, dbname from accounts where type="P" and username = ?'); $stmt->execute([$user]); $arr=$stmt->fetch(PDO::FETCH_NUM); if(!$arr) exit('Not Found! Contact IT. Error-code: 0001'); $Pwd=$arr[0]; $host=$arr[1]; $dbName=$arr[2]; //----------------------------------// //-----> Connect to MSSQL <-----// //----------------------------------// //---> $host = "hth-vd-lda01.ngcorp.global" ; //---> Development <---// $host = "hth-vp-lda01.ngcorp.global" ; $dbName = "NGC-Tico" ; //---> echo 'Host => '.$host.'
'.' DB => '.$dbName.'
'.'User => '.$user.'
'.'PWD => '.$Pwd.'
'; try { $con = new PDO( "sqlsrv:server=$host;Database=$dbName;TrustServerCertificate=true", $user, $Pwd ); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch(PDOException $e) { die("Error connecting to SQL Server: ".$e->getMessage()); } ?>