Cannot pass parameter 2 by reference - uuid PDO
The second argument to bindParam
is passed by reference and should be a variable. You are directly passing the values which is not allowed.
Place UUID()
directly in the query because if it is bound as a parameter, it would be placed in the query as a quoted string and will not be evaluated to a UUID value.
You can place the 1
directly in the query too. Or assign 1
to a variable and give that variable as the second argument while binding the parameter :type_id
.
$type_id = 1;
$stmt->bindParam(':type_id', $type_id, PDO::PARAM_INT);
There's no need to bind it in this case, simply include it in your query:
$query = "INSERT INTO users (users_uuid, type_id) VALUES (UUID(), :type_id)";
..then bind :type_id
as you already are.