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
Add parenthesis:
$stmt->bind_param("ss", $user, (md5($pass . $this->salt)));
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);
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.
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.