我收到错误: 无法通过引用传递参数 2 in.....
在这一行...
$stmt1->bindParam(':value', $_SESSION['quantity'.$i] * $_SESSION['price'.$i], PDO::PARAM_STR);
上面的代码有什么问题??
最佳答案
我会说这是 PDO:bindParam() 之间的典型混淆以及您可能打算使用的内容:PDO:bindValue() .
PDOStatement::bindParam
Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement. Unlike
PDOStatement::bindValue()
, the variable is bound as a reference and will only be evaluated at the time thatPDOStatement::execute()
is called.
PDOStatement::bindValue
Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.
关于php - 无法通过 php PDO 中的引用错误传递参数 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24980136/