title: $_SESSION variable in mysql query?
body: <p>Whenever I try a query like:</p>
  
  <pre><code>mysql_query("SELECT * FROM data WHERE `user`=$_SESSION['valid_user'] LIMIT 1");
  </code></pre>
  
  <p>it doesn't work. Why? I escaped the variable, then tried it without, and tried putting quotes around the variable. I know i can do:</p>
  
  <pre><code>$user = $_SESSION['valid_user'];
  </code></pre>
  
  <p>but shouldn't it work without? Thanks.</p>
  
  <p>THE ANSWER:</p>
  
  <p>PHP can't recognize $_SESSION['valid_user'] due to the single quotes. So either 
  use curly braces {} or take our the single quotes.</p>
  
  <p>Thanks for helping me everyone.</p>