title: php connecting to mysql on localhost, request from remote
body: <p>I have a wamp server running on my local machine that is exposed to the outside world.  I have several php scripts that allow an android app to access information contained in a mySQL database running on the same machine as the WAMP server.  When tested from inside my local network everything works fine.  However when I try to run the php scripts from outside my local network there appears to be an error connecting to mySQL.</p>
  
  <p>connect.php</p>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *'); 
  
  /*** mysql hostname ***/
  $hostname = '127.0.0.1';
  
  /*** mysql username ***/
  $username = 'chaosjr_user';
  
  /*** mysql password ***/
  $password = 'pass';
  
  try {
      $dbh = new PDO("mysql:host=$hostname;dbname=chaos_jr", $username, $password);
      $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      }
  catch(PDOException $e)
      {
      echo $e-&gt;getMessage();
      }
  ?&gt;
  </code></pre>
  
  <p>I'm almost certain it has something to do with the fact I'm referencing localhost from the outside world, but when I replace 127.0.0.1 with the IP address on my internal network or the external IP address it doesn't work from anywhere.  Any suggestions?</p>
  
  <p>EDIT:
  Just to clarify, I can get to my php scripts from the outside (I do have a static IP address) and get a response from them as long as that particular script does't have to query MySQL.  For example I can connect to XXX.XXX.XXX.XXX/myPHPscript.php just fine and everything looks good.  But menus that are supposed to populate with SQL data are empty.</p>