严格的标准:只有变量才能通过第14行的参考传递

时间:2017-05-04 09:43:58

标签: php pdo

我收到错误Strict standards: Only variables should be passed by reference on line 14

<?php
require 'database.php';
$messaqage = '';

if(!empty($_POST['email']) && !empty($_POST['password'])):

    // Enter the new user in the database
    $sql = "INSERT INTO users (email, password) VALUES (:email, :password)";
    $stmt = $conn->prepare($sql);

    $stmt->bindParam(':email',$_POST['email']);
    $stmt->bindParam(':password',password_hash($_POST['password'],PASSWORD_BCRYPT));

    if( $stmt->execute() ):
        $message = 'Successfully created new user';
    else:
        $message = 'Sorry there must be an issue creating your account';
    endif;

endif;

?>

我无法解决此错误。我无法调试此问题。

提前致谢

1 个答案:

答案 0 :(得分:0)

bindParam()第二个参数是一个参考。传递函数结果。像这样改变。

$password = password_hash($_POST['password'],PASSWORD_BCRYPT); 
$stmt->bindParam(':password',$password);