0

I am trying to develop a PHP app in heroku using php....

I have done adding up the add on using the link - https://devcenter.heroku.com/articles/xeround#connecting-to-xeround.

Now, I was trying to query the the database yung just a simple query but not displaying even any errors.

May I know if a connection string is still required? and if required, may I know what to put as the host?

If any follow up question is required, please let me know.

Thanks in advance!

goryo
  • 26
  • 6

1 Answers1

0

You can try this:

$url=parse_url(getenv("DATABASE_URL"));

$server = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$port = $url["port"];
$db = substr($url["path"],1);

$link = mysql_connect($server . ":" . $port, $username, $password);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

[Source: https://devcenter.heroku.com/articles/cleardb#using-cleardb-with-php]

Hope it helps :)

karmiphuc
  • 81
  • 1
  • 9