title: Connect to an online MySQL database from localhost
body: <p>I am trying to connect to my MySQL database on my online server via PHP on my localhost.</p>
  
  <pre><code>$con = mysql_connect("$hostname", "$username", "$password");
  if (!$con) {die('Could not connect: ' . mysql_error());}
  mysql_select_db($databasename, $con);
  </code></pre>
  
  <p>When I upload the script to the server it connects to the database fine.  However, when I load the script on my localhost it will not connect to the online database.  I shut off my firewall to make sure it was not blocking it.</p>
  
  <p>Is the connection above formatted correctly to do this? Any other suggestions?</p>