Strict Standards: Only variables should be passed by reference in m_auth

前端 未结 4 1178
栀梦
栀梦 2020-12-22 14:16

I am working on a login system for a project using MVC programming and ran into this error. Here is the code, the problem line is #31

This login system is a tutoria

相关标签:
4条回答
  • 2020-12-22 14:56

    Add parenthesis:

    $stmt->bind_param("ss", $user, (md5($pass . $this->salt)));
    
    0 讨论(0)
  • 2020-12-22 15:11

    bind_param's params are references to variables. You can't use md5() there. You need to save it to a variable first.

    $userPass = md5($pass . $this->salt);
    $stmt->bind_param("ss", $user, $userPass);
    
    0 讨论(0)
  • 2020-12-22 15:12

    The problem is that the 3rd parameter is the result of a function call:

    md5($pass . $this->salt)

    You need to save that value to a variable before passing it to bind_param so that it can be passed by reference.

    Example:

    $password = md5($pass . $this->salt);  
    $stmt->bind_param("ss", $user, $password);
    

    Also, don't use md5 to hash passwords.

    0 讨论(0)
  • 2020-12-22 15:13

    This was likely fixed in PHP 5.4 as part of Function Array Dereferencing (FAD) (revision 300266).

    Alternatively as workaround try adding extra brackets, e.g.

    $stmt->bind_param("ss", $user, (md5($pass . $this->salt)));
    

    which would dereference the method/function return, see: (<5.6) Occasionally significant parentheses.

    0 讨论(0)
提交回复
热议问题