【问题标题】:Strict standards: Only variables should be passed by reference on line 14 [duplicate]严格标准:第 14 行仅应通过引用传递变量 [重复]
【发布时间】:2017-05-04 09:43:58
【问题描述】:

我收到错误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;

?>

我一直在解决这个错误。我无法调试问题。

提前致谢

【问题讨论】:

  • 你不能认为这是一个问题,这里显示的是一堆代码。请添加一些解释。
  • $password = password_hash($_POST['password'],PASSWORD_BCRYPT); $stmt->bindParam(':password',$password);

标签: php pdo


【解决方案1】:

bindParam() 第二个参数是一个引用。你传递一个函数结果。改成这样。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    • 2015-05-27
    • 2016-10-05
    • 2014-08-17
    • 1970-01-01
    相关资源
    最近更新 更多