title: PHP / SQL - Escaping characters in a variable
body: <p>I have the following code on 1 page that works perfectly fine: </p>
  
  <pre><code> $log = "UPDATE users SET loggedIn = '1' WHERE username= '$username' ";
  </code></pre>
  
  <p>However, upon changing that code slightly, something is going wrong escaping my characters. </p>
  
  <pre><code>$log = "UPDATE users SET loggedIn = '0' WHERE username= '$_SESSION["username"]' ";
  </code></pre>
  
  <p>The issue lies within my syntax here: <strong>'$_SESSION["username"]'</strong></p>
  
  <p>Unfortunately, the $username variable is not declared in this page. <br />
  HOWEVER, $_SESSION['username'] is declared, and an echo of it returns exactly what I need.</p>
  
  <p>I've been trying different variations of single quotes, double quotes, and backslashes for hours. Can someone tell me what I am doing wrong? ..</p>
  
  <p><em><h3>Solved by Enstage</h3></em></p>