douxin8610 2011-08-11 14:39
浏览 22
已采纳

PHP / MySQL - 使用会话数据更新表数据

How to update table data with data stored in session?

I have following code but it is not working(INSERTING INTO DB not working exactly). Please not that this is just part of the code. Session value are being saved correctly. I have a problem with saving them though.

If I have made silly mistake - apologies - I'm newby.

    $loggedTime = $_SESSION['loggedtime'];
    $thisUser = $_SESSION['usr'];

    $result = mysql_query("UPDATE 'admin' SET dt = $loggedTime WHERE $thisuser");
    if($result) {
         echo "success"; 
    } else { 
        echo "no success"; 
    }
  • 写回答

4条回答 默认 最新

  • douyu7618 2011-08-11 14:41
    关注
    "UPDATE `admin` SET `dt` = '$loggedTime' WHERE user = '$thisUser'"
    

    Don't use single quotes around column/table names. Single/double quotes indicate string literals. Use back ticks around table/column names, if you have to (i.e. reserved word). Also, have a look at Bobby Tables. Furthermore, you need a column in the where clause.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退