title: PHP MySQL: Query with Less Than AND Greater Than
body: <p>I have the following mysql query in my PHP file:</p>
  
  <pre><code>$shopID   = mysql_real_escape_string($_GET['shop_id']);
  $latitudeCenter = mysql_real_escape_string($_GET['lat_center']);
  $longtitudeCenter = mysql_real_escape_string($_GET['lng_center']);
  
  $lat_min = $latitudeCenter - 0.045;
  $lat_max = $latitudeCenter + 0.045;
  $long_min = $longtitudeCenter - (0.045 / cos($latitudeCenter*M_PI/180);
  $long_max = $longtitudeCenter + (0.045 / cos($latitudeCenter*M_PI/180);
  
  $sql = "SELECT * FROM shops WHERE shop_id = '$shopID' AND lat &gt;= '$lat_min' AND lat &lt;= '$lat_max' AND lng &gt;= '$long_min' AND lng &lt;= '$long_max'";
  </code></pre>
  
  <p>For some reason the query is not running successfully. Is the above query valid?
  Thanks</p>
  
  <p>EDIT:</p>
  
  <p>There is something wrong with the $long_min and $long_max calculations as when they are commented out, it works ok. </p>
  
  <p>Here is the code I tried to conver to PHP:</p>
  
  <pre><code>lat_min = lat_center - 0.045;
  lat_max = lat_center + 0.045;
  long_min = long_center - (0.045 / Math.cos(lat_center*Math.PI/180);
  long_max = long_center + (0.045 / Math.cos(lat_center*Math.PI/180);
  </code></pre>
  
  <p>What is wrong with my PHP?</p>