【问题标题】:PDOStatement wrong result on checkPDOStatement 检查结果错误
【发布时间】:2018-08-02 00:40:45
【问题描述】:

我有这个代码:

$PDOStatement = $pdo->prepare("INSERT INTO users (ID, email, password) VALUES(?, ?, ?)");

    if($PDOStatement->execute($uuid, $email,$encrypted_password))
    {
        echo "test";
        return true;
    }

数据被输入到数据库中,但不幸的是 IF 没有给出回显或返回。

提前致谢!

【问题讨论】:

  • 去掉退货
  • 为什么这个标签是mysqli?
  • @FunkFortyNiner 嗨,感谢您的快速回答:) 我在之前没有工作后附上了退货
  • 而且,好吧,我对 MySQL 很陌生,基本上是从本周开始的,在一个页面上我看到了 MySQLi,另一个说只有 MySQL,所以我不清楚。
  • 在你的 IF 之外,试试print_r($PDOStatement->errorInfo()); 那会输出什么?

标签: php database mysqli pdo statements


【解决方案1】:

需要将参数作为数组传递:

if($PDOStatement->execute($uuid, $email,$encrypted_password))

应该是

if($PDOStatement->execute([$uuid, $email,$encrypted_password]))

(手动:http://php.net/manual/en/pdostatement.execute.php

【讨论】:

    猜你喜欢
    • 2013-12-26
    • 2013-06-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-27
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多