title: Get variable from session storage and use in PHP query
body: <p>I am trying to get a variable from session storage and use it in my PHP MySQL query, but it keeps returning no values.</p>
  
  <p>My JavaScript to get variables from session storage:</p>
  
  <pre><code>var myEmail = sessionStorage.getItem('myEmail'); 
  </code></pre>
  
  <p>Assigning a JavaScript variable to a PHP variable:</p>
  
  <pre><code>&lt;?php
         $emailAddress = "&lt;script&gt;document.write(myEmail);&lt;/script&gt;";
  ?&gt;
  </code></pre>
  
  <p>And once connected to the database:</p>
  
  <pre><code>&lt;?php
         $query = mysql_query("SELECT * FROM myTable WHERE emailaddress='$emailAddress';
  ?&gt;
  </code></pre>
  
  <p>Can anyone see any problems? When I output the result it is just blank. Just before I make the query I echoed the email address and it output fine. Not sure when I put it in the query it just returns nothing. If i change the <code>$emailAddress</code> in the query for "someone@gmail.com" for example it works fine, just not with the variable.</p>