Advertisement
Guest User

Untitled

a guest
May 4th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. $connstr = getenv("MYSQLCONNSTR_MySqlDB");
  3. //echo "MySQL Connection String is".$connstr;
  4. foreach ($_SERVER as $key => $value)
  5. {
  6. if (strpos($key, "MYSQLCONNSTR_") !== 0)
  7. {
  8. continue;
  9. }
  10. $hostname = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
  11. $username = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
  12. $password = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
  13. break;
  14. }
  15. echo "Server Name: ".$hostname."</br>";
  16. /* now you can use the $host, $username, $password like you normally would */
  17. $con = mysql_connect($host, $username, $password);
  18. //connection to the database
  19. $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
  20. echo "<br>Connected to MySQL</br>";
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement