Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connstr = getenv("MYSQLCONNSTR_MySqlDB");
- //echo "MySQL Connection String is".$connstr;
- foreach ($_SERVER as $key => $value)
- {
- if (strpos($key, "MYSQLCONNSTR_") !== 0)
- {
- continue;
- }
- $hostname = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
- $username = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
- $password = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
- break;
- }
- echo "Server Name: ".$hostname."</br>";
- /* now you can use the $host, $username, $password like you normally would */
- $con = mysql_connect($host, $username, $password);
- //connection to the database
- $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
- echo "<br>Connected to MySQL</br>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement