donglu5000 2014-03-05 21:38
浏览 53
已采纳

MySQLi更新DATETIME列

I know this is going to be something simple, but it's driving me a little insane at the moment. I need to update my datetime column with my statement, however it's not working. Any ideas?

$stmt = $db->prepare("UPDATE clients SET client_last_date = NOW() WHERE client_id = ?"))
$stmt->bind_param("i", $_SESSION['client_id']);
$stmt->execute();
$stmt->close();

The error i'm getting is Fatal error: Call to undefined method PDOStatement::bind_param()

EDIT - Turns out there was conflicting PDO objects inside a login script im using, that was causing my error. All sorted now!

  • 写回答

2条回答 默认 最新

  • donglu1472 2014-03-05 21:49
    关注

    I think it's written otherwise in PDO:

    $stmt->bind_param("i", $_SESSION['client_id']);
    

    should be

    $stmt->bindParam(1, $_SESSION['client_id']);
    

    in mysqli it would be bind_param but the error speaks of PDO. $db must be a PDO ressource...

    mysqli http://ca.php.net/manual/en/mysqli-stmt.bind-param.php

    pdo http://www.php.net/manual/en/pdostatement.bindparam.php

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

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM