title: PHP connect to external MySQL Database
body: <p>im trying to connect to my external sql database but I keep getting this error:</p>
  
  <pre><code>mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\zconnect.php on line 10
  Unable to connect to database! Please try again later.
  </code></pre>
  
  <p>This is the PHP script:</p>
  
  <pre><code>&lt;?php
  $hostname='111.11.111.11'; #this is not my real ip address
  $username='root';
  $password='password';
  $dbname='database';
  $usertable='users';
  $yourfield = 'admin';
  
  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>Tried this but didn't work also:</p>
  
  <pre><code>Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.1.14/"
  
  # to give access to phpmyadmin from outside 
  # replace the lines
  #
  # Require local
  #
  # by
  #
  # Require all granted
  #
  </code></pre>
  
  <p>Any help is appreciated!</p>