title: Remotely connecting to a MySQL database
body: <p>I've just set up a MySQL database on a web-hosting service and I'm trying to connect to it remotely using the following php:</p>
  
  <pre><code>&lt;?php
  //Connect To Database
  $hostname='113.101.88.97.ukld.db.5513497.hostedresource.com';
  $username='myusername';
  $password='mypassword';
  $dbname='testdb';
  $usertable='test';
  $yourfield = 'lat';
  
  mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  mysql_select_db($dbname);
  
  $query = 'SELECT * FROM ' . $usertable;
  $result = mysql_query($query);
  if($result) {
      while($row = mysql_fetch_array($result)){
          print $name = $row[$yourfield];
          echo 'Name: ' . $name;
      }
  }
  else {
  print "Database NOT Found ";
  mysql_close($db_handle);
  }
  ?&gt;
  </code></pre>
  
  <p>I'm quite new to php and MySQL, and I don't understand a few things. I have saved the above code in a file (called demo.html) and I try viewing it in my web browser (it currently does not show anything).</p>
  
  <p>My hosting company told me that to connect to the database I should use </p>
  
  <pre><code>ukld.db.5513497.hostedresource.com
  </code></pre>
  
  <p>I assumed that I needed to include the IP address (what I see when I login using PhPMyAdmin), so I added that also. However, I don't know if that is structured correctly.</p>
  
  <pre><code>$hostname='113.101.88.97.ukld.db.5510597.hostedresource.com';
  </code></pre>