title: How to make connection to heroku mysql database
body: <p>I created a web app that I was able to successfully deploy to heroku. The site uses a mysql database that I dumped into the project directory for the app. I followed the instructions from <a href="https://stackoverflow.com/questions/14947506/using-mysql-with-php-on-heroku">this SO post</a> as well as other online sources.  I entered the following command into the terminal:</p>
  
  <pre><code> heroku config | grep CLEARDB_DATABASE_URL
  </code></pre>
  
  <p>and got the CLEARDB_DATABASE_URL: mysql://be4beb15e4506b:f601032d@us-cdbr-iron-east-02.cleardb.net/heroku_e665c17e181f638?reconnect=true</p>
  
  <p>Before deploying the app I then entered:</p>
  
  <pre><code> mysql -u be4beb15e4506b  -h us-cdbr-iron-east-02.cleardb.net -p heroku_e665c17e181f638 &lt; /var/www/html/Clubhub.sql
  </code></pre>
  
  <p>Inside of the actual files, I added the following code for the database connection:</p>
  
  <pre><code>url = parse_url(getenv(" mysql://be4beb15e4506b:f601032d@us-cdbr-iron-east-02.cleardb.net/heroku_e665c17e181f638?reconnect=true"));
  $server = $url["us-cdbr-iron-east-02.cleardb.net"];
  $username = $url["be4beb15e4506b"];
  $password = $url["heroku_e665c17e181f638"];
  $db = substr($url["/var/www/html/Clubhub.sql"], 1);
  $connection = new mysqli($server, $username, $password, $db);
  </code></pre>
  
  <p>For some reason whenever I navigate to a page where a query is done, I'm getting a connection error. Based on the url provided, have the correct arguments been passed to the connection?</p>