title: Variable in SQL Query Not Working?
body: <pre><code>    if (isset($_SESSION['user_tz'])) {
          $posted = "CONVERT_TZ(p.posted_on, 'UTC', '{$_SESSION['user_tz']}')";
      } else {
          $posted = 'p.posted_on';
      }
  
      // Run the query:
      $q = "SELECT t.subject, p.message, username, DATE_FORMAT($posted, '%e-%b-%y %l:%i %p') AS posted FROM threads AS t LEFT JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON p.user_id = u.user_id WHERE t.thread_id = $tid ORDER BY p.posted_on ASC";
  </code></pre>
  
  <p>I changed the $posted in the query to a plain "posted_on" which returned the time, I also tried some wrapping it in '' and "" but those ended up breaking it entirely; for future reference I'd like to know why that variable isn't getting passed through to the query. It's probably something really simple and I'll feel silly but help would be appreciated greatly.</p>
  
  <p>Thanks.</p>