php - 无法通过 php PDO 中的引用错误传递参数 2

标签 php pdo

我收到错误: 无法通过引用传递参数 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 that PDOStatement::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/

相关文章:

javascript - 如何使用Jquery和Ajax将Json数据发送到数据库?

php - 在服务器上用 PHP 解析 HTML 还是在最终用户端用 JavaScript 解析 HTML 会更好?

mysql - PHP PDO 在 Mysql 中插入 Longditude/latituded 并在插入前检查是否存在

php - SQL 没有获取第二行的 ID

php - 如何将连接表的结果实体封装在 Doctrine 中的另一个实体中?

php - 永久链接不适用于 MySQL 数据库

php - 未创建 Wordpress 图像缩略图

php - 用 Dompdf 指定字体?

php - 当密码为空时,Windows 上的 PDO 会忽略主机名和用户名

php - 使用 Php 将嵌套的 JSON 插入 mySQL