title: PHP: cannot pass single quoted string to mysqli query
body: <p>I was fighting for hours with this simply thing:</p>
  
  <pre><code>$var=var;    
  $result = "SELECT column1, column2 FROM $db WHERE column3 = '$var' ";
  </code></pre>
  
  <p>The error I get is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'var\'' at line 1</p>
  
  <p>Names are correct, it works in mysql query. Think I tried all possible quoting options, what is wrong?</p>
  
  <p>UPDATE: as requested I used the escaping, but error remains the same</p>
  
  <pre><code>$var=var;   
  $var = $conn-&gt;real_escape_string($var);
  $result = "SELECT column1, column2 FROM {$db} WHERE column3 = '{$var}' ";
  </code></pre>