2011-04-16 01:08
浏览 47


    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";

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.


图片转代码服务由CSDN问答提供 功能建议

  if(isset($ _ SESSION ['user_tz'])){
 $ posted =“CONVERT_TZ  (p.posted_on,'UTC','{$ _SESSION ['user_tz']}')“; 
} else {
 $ posted ='p.posted_on'; 
 //运行 查询:
 $ q =“SELECT t.subject,p.message,username,DATE_FORMAT($ posted,'%e-%b-%y%l:%i%p')AS从线程发布AS t LEFT JOIN  post AS p USING(thread_id)INNER JOIN用户AS u ON p.user_id = u.user_id WHERE t.thread_id = $ tid ORDER BY p.posted_on ASC“; 
 < 我将查询中发布的$更改为一个简单的“posted_on”,它返回了时间,我也尝试将其包装在''和“”中,但最终完全打破了它; 为了将来参考,我想知道为什么该变量没有传递给查询。 这可能是非常简单的事情,我会感到愚蠢,但我会非常感激帮助。 


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • dongzhoulong1797 2011-04-16 01:29

    NULL is a valid value for isset() to trigger TRUE. Use unset($_SESSION['user_tz']);

    解决 无用
    打赏 举报

相关推荐 更多相似问题