title: PHP - Single quotes or double quotes around SQL query?
body: <p>Is there any differences in using single quotes vs. using double quotes around a whole SQL query?</p>
  
  <p>Which is better:</p>
  
  <p>This approach (with single quotes):</p>
  
  <pre><code>    $username = mysql_real_escape_string($username);
      $password = mysql_real_escape_string($password);
  
      $sql = 'SELECT * FROM users WHERE username = "' . $username . '" AND password = "' . $password . '" LIMIT 1';
  </code></pre>
  
  <p>?</p>
  
  <p>Or this approach (using double quotes):</p>
  
  <pre><code>    $username = mysql_real_escape_string($username);
      $password = mysql_real_escape_string($password);
  
      $sql = "SELECT * FROM users WHERE username = '{$username}' AND password = '{$password}' LIMIT 1";
  </code></pre>
  
  <p>Is there a better way to accomplish this?</p>
  
  <p>For me I like the first approach as I always prefer single quotes in PHP. So I want to make sure that using single quotes around a whole SQL query is OK and using double quotes around variables or data is OK and is cross-platform and could be used with databases other than MySQL!</p>