I'm starting to learn to program in PHP, and right now I'm doing a simple web. As it says in the title, I have the error of: "Only variables should be passed by reference in". Which is not an error since the code does what I want it to do (which is to add users to my DB).
The code that produces the error is the following:
$stmt -> bindParam(':nombre', $usuario -> obtener_nombre(), PDO::PARAM_STR);
$stmt -> bindParam(':email', $usuario -> obtener_nombre(), PDO::PARAM_STR);
$stmt -> bindParam(':password', $usuario -> obtener_nombre(), PDO::PARAM_STR);
Who, searching the Internet, found a possible solution, which is:
$nombreUser = $usuario -> obtener_nombre();
$$sentencia -> bindParam(':nombre', $nombreUser, PDO::PARAM_STR);
$emailUser = $usuario -> obtener_nombre();
$sentencia -> bindParam(':email', $emailUser, PDO::PARAM_STR);
$passwordUser = $usuario -> obtener_nombre();
$sentencia -> bindParam(':password', $passwordUser, PDO::PARAM_STR);
But now another problem arose, when changing the value ': name' to ': email', ': password', every time I register a new user, the values email and password take the values that are named .
I understand that the problem is in the solution I found, since I am telling my code that the value that $ user takes will be added to email and password.
Some solution to this problem