Cannot pass parameter 2 by reference error in php PDO

前端 未结 2 1982
广开言路
广开言路 2021-01-15 03:51

I am getting the error: Cannot pass parameter 2 by reference in.....

in this line...

$stmt1->bindParam(\':value\', $_SESSION[\'quantity\'.$i] * $_         


        
2条回答
  •  无人及你
    2021-01-15 03:59

    I'd say it's the typical confusion between PDO:bindParam() and what you probably intended to use: 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.

提交回复
热议问题